diff --git a/ChangeLog b/ChangeLog index daef3c0..06d0f23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Buxfixes: * `argbash-init` is able to handle empty string as the only argument without being puzzled (#130). +* Error handling of script working directory detection now more robust (#134). New features: diff --git a/bin/argbash b/bin/argbash index 934600f..e0bfdaf 100755 --- a/bin/argbash +++ b/bin/argbash @@ -246,7 +246,7 @@ handle_passed_args_count assign_positional_args 1 "${_positionals[@]}" # OTHER STUFF GENERATED BY Argbash -script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2 +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; } # Validation of values diff --git a/src/stuff.m4 b/src/stuff.m4 index dc36c3b..5b17ede 100644 --- a/src/stuff.m4 +++ b/src/stuff.m4 @@ -137,7 +137,7 @@ m4_define([_DEFINE_SCRIPT_DIR], [m4_do( [m4_define([SCRIPT_DIR_DEFINED])], [m4_define([_SCRIPT_DIR_NAME], m4_ifnblank([$1], [[$1]], _DEFAULT_SCRIPTDIR))], [m4_list_append([_OTHER], - m4_quote(_SCRIPT_DIR_NAME[="$($2)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2]))], + m4_quote(_SCRIPT_DIR_NAME[="$($2)" || ]_INLINE_DIE_BLOCK([Couldn't determine the script's running directory, which probably matters, bailing out], 2)))], )]) diff --git a/src/utilities.m4 b/src/utilities.m4 index 5f31793..2a10a8f 100644 --- a/src/utilities.m4 +++ b/src/utilities.m4 @@ -318,6 +318,14 @@ m4_define([_LIST_LONGEST_TEXT_LENGTH], [m4_do( m4_define([_CAPITALIZE], [m4_translit([[$1]], [a-z], [A-Z])]) +dnl +dnl $1: The message - will be double-quoted +dnl $2: The return code (default = 1) +m4_define([_INLINE_DIE_BLOCK], [m4_do( + [[{ echo "$1" >&2; exit ]m4_default_quoted([$2], 1); }], +)]) + + dnl dnl $1: What to underline dnl $2: By what to underline