Skip to content

Commit 80072e4

Browse files
committed
breaking: Deprecate print_die functions
These functions were initially used because a 'die' function is necessary in most scripts. Because of othe other `_fn`s, a `print_die_fn` was made, which makes little sense, as if the function name is required to be printed on fault, it would be better to show the stacktrace anyways (and implement some functionality for that) There was also an issue of switching the `die` function from calling `core.print_error` to `core.print_fatal`. This semantically causes some issues; for example, internal faults should be treated as "fatal", while user-input errors should be treated as "errors". Any `die` functions should be created at hyperupcall/bash-std
1 parent 7ecc1ec commit 80072e4

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

docs/api.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ Core functions for any Bash program
1515
* [core.err_exists()](#coreerr_exists)
1616
* [core.panic()](#corepanic)
1717
* [core.print_stacktrace()](#coreprint_stacktrace)
18-
* [core.print_die_fn()](#coreprint_die_fn)
1918
* [core.print_fatal_fn()](#coreprint_fatal_fn)
2019
* [core.print_error_fn()](#coreprint_error_fn)
2120
* [core.print_warn_fn()](#coreprint_warn_fn)
2221
* [core.print_info_fn()](#coreprint_info_fn)
2322
* [core.print_debug_fn()](#coreprint_debug_fn)
24-
* [core.print_die()](#coreprint_die)
2523
* [core.print_fatal()](#coreprint_fatal)
2624
* [core.print_error()](#coreprint_error)
2725
* [core.print_warn()](#coreprint_warn)
@@ -31,6 +29,8 @@ Core functions for any Bash program
3129
* [core.get_package_info()](#coreget_package_info)
3230
* [core.init()](#coreinit)
3331
* [core.stacktrace_print()](#corestacktrace_print)
32+
* [core.print_die_fn()](#coreprint_die_fn)
33+
* [core.print_die()](#coreprint_die)
3434

3535
### core.trap_add()
3636

@@ -160,15 +160,6 @@ core.trap_add 'err_handler' ERR
160160

161161
_Function has no arguments._
162162

163-
### core.print_die_fn()
164-
165-
Print a error message to standard error including the function name
166-
of the callee to standard error and die
167-
168-
#### Arguments
169-
170-
* **$1** (string): message
171-
172163
### core.print_fatal_fn()
173164

174165
Print a fatal error message including the function name of the callee
@@ -214,14 +205,6 @@ to standard output
214205

215206
* **$1** (string): message
216207

217-
### core.print_die()
218-
219-
Print a error message to standard error and die
220-
221-
#### Arguments
222-
223-
* **$1** (string): message
224-
225208
### core.print_fatal()
226209

227210
Print a fatal error message to standard error
@@ -296,3 +279,20 @@ _Function has no arguments._
296279

297280
* [core.print_stacktrace](#coreprint_stacktrace)
298281

282+
### core.print_die_fn()
283+
284+
(DEPRECATED) Print a error message to standard error including the function name
285+
of the callee to standard error and die
286+
287+
#### Arguments
288+
289+
* **$1** (string): message
290+
291+
### core.print_die()
292+
293+
(DEPRECATED) Print a error message to standard error and die
294+
295+
#### Arguments
296+
297+
* **$1** (string): message
298+

pkg/src/public/bash-core.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,6 @@ core.print_stacktrace() {
285285
fi
286286
} >&2
287287

288-
# @description Print a error message to standard error including the function name
289-
# of the callee to standard error and die
290-
# @arg $1 string message
291-
core.print_die_fn() {
292-
local msg="$1"
293-
294-
core.print_die "${FUNCNAME[1]}()${msg:+": "}$msg"
295-
}
296-
297288
# @description Print a fatal error message including the function name of the callee
298289
# to standard error
299290
# @arg $1 string message
@@ -338,13 +329,6 @@ core.print_debug_fn() {
338329
core.print_debug "${FUNCNAME[1]}()${msg:+": "}$msg"
339330
}
340331

341-
# @description Print a error message to standard error and die
342-
# @arg $1 string message
343-
core.print_die() {
344-
core.print_fatal "$1"
345-
exit 1
346-
}
347-
348332
# @description Print a fatal error message to standard error
349333
# @arg $1 string message
350334
core.print_fatal() {
@@ -446,4 +430,20 @@ core.init() {
446430
core.stacktrace_print() {
447431
core.print_warn "The function 'core.stacktrace_print' is deprecated in favor of 'core.print_stacktrace'"
448432
core.print_stacktrace "$@"
433+
}
434+
435+
# @description (DEPRECATED) Print a error message to standard error including the function name
436+
# of the callee to standard error and die
437+
# @arg $1 string message
438+
core.print_die_fn() {
439+
local msg="$1"
440+
441+
core.print_die "${FUNCNAME[1]}()${msg:+": "}$msg"
442+
}
443+
444+
# @description (DEPRECATED) Print a error message to standard error and die
445+
# @arg $1 string message
446+
core.print_die() {
447+
core.print_fatal "$1"
448+
exit 1
449449
}

0 commit comments

Comments
 (0)