Skip to content

Commit 0466f21

Browse files
committed
Introduce and use inline die for cases when its not available.
s.a error handing of script's directry detection. Fixes: #134
1 parent e8d9dd8 commit 0466f21

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Diff for: ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Buxfixes:
55

66
* `argbash-init` is able to handle empty string as the only argument without being puzzled (#130).
7+
* Error handling of script working directory detection now more robust (#134).
78

89
New features:
910

Diff for: bin/argbash

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ handle_passed_args_count
246246
assign_positional_args 1 "${_positionals[@]}"
247247

248248
# OTHER STUFF GENERATED BY Argbash
249-
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2
249+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || { echo "Couldn't determine the script's running directory, which probably matters, bailing out" >&2; exit 2; }
250250
# Validation of values
251251

252252

Diff for: src/stuff.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ m4_define([_DEFINE_SCRIPT_DIR], [m4_do(
137137
[m4_define([SCRIPT_DIR_DEFINED])],
138138
[m4_define([_SCRIPT_DIR_NAME], m4_ifnblank([$1], [[$1]], _DEFAULT_SCRIPTDIR))],
139139
[m4_list_append([_OTHER],
140-
m4_quote(_SCRIPT_DIR_NAME[="$($2)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2]))],
140+
m4_quote(_SCRIPT_DIR_NAME[="$($2)" || ]_INLINE_DIE_BLOCK([Couldn't determine the script's running directory, which probably matters, bailing out], 2)))],
141141
)])
142142

143143

Diff for: src/utilities.m4

+8
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ m4_define([_LIST_LONGEST_TEXT_LENGTH], [m4_do(
318318
m4_define([_CAPITALIZE], [m4_translit([[$1]], [a-z], [A-Z])])
319319
320320
321+
dnl
322+
dnl $1: The message - will be double-quoted
323+
dnl $2: The return code (default = 1)
324+
m4_define([_INLINE_DIE_BLOCK], [m4_do(
325+
[[{ echo "$1" >&2; exit ]m4_default_quoted([$2], 1); }],
326+
)])
327+
328+
321329
dnl
322330
dnl $1: What to underline
323331
dnl $2: By what to underline

0 commit comments

Comments
 (0)