Skip to content

Commit

Permalink
Merge pull request #137 from matejak/no_die_yet
Browse files Browse the repository at this point in the history
Introduce and use inline die for cases when its not available.
  • Loading branch information
matejak committed Sep 21, 2020
2 parents e8d9dd8 + 0466f21 commit 530f5e2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion bin/argbash
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/stuff.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)))],
)])


Expand Down
8 changes: 8 additions & 0 deletions src/utilities.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 530f5e2

Please sign in to comment.