From 16a5ba294b1d51695a863028c8fe7b577c363287 Mon Sep 17 00:00:00 2001 From: Hannes Leutloff Date: Fri, 13 Jun 2025 18:30:19 +0200 Subject: [PATCH 1/3] Show basename of script in usage text --- bin/argbash | 2 +- bin/argbash-1to2 | 2 +- bin/argbash-init | 2 +- src/stuff.m4 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/argbash b/bin/argbash index 4e344b9..66cbefa 100755 --- a/bin/argbash +++ b/bin/argbash @@ -86,7 +86,7 @@ _arg_debug= print_help() { printf '%s\n' "Argbash is an argument parser generator for Bash." - printf 'Usage: %s [-o|--output ] [-i|--(no-)in-place] [-t|--type ] [--(no-)library] [--strip ] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search ] [--debug ] [-h|--help] [-v|--version] \n' "$0" + printf 'Usage: %s [-o|--output ] [-i|--(no-)in-place] [-t|--type ] [--(no-)library] [--strip ] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search ] [--debug ] [-h|--help] [-v|--version] \n' "$(basename "$0")" printf '\t%s\n' ": The input template file (pass '-' for stdin)" printf '\t%s\n' "-o, --output: Name of the output file (pass '-' for stdout) (default: '-')" printf '\t%s\n' "-i, --in-place, --no-in-place: Update a bash script in-place (off by default)" diff --git a/bin/argbash-1to2 b/bin/argbash-1to2 index 98fba43..91e532b 100755 --- a/bin/argbash-1to2 +++ b/bin/argbash-1to2 @@ -42,7 +42,7 @@ _arg_output="" print_help() { printf '%s\n' "Convert a template for argbash>=1,<2 to argbash>=2,<3" - printf 'Usage: %s [-o|--output ] [-v|--version] [-h|--help] [] ... [] ...\n' "$0" + printf 'Usage: %s [-o|--output ] [-v|--version] [-h|--help] [] ... [] ...\n' "$(basename "$0")" printf '\t%s\n' ": The input file to transform" printf '\t%s\n' "-o, --output: Name of the output file (pass '-' for stdout and empty string for the same as input file) (default: '""')" printf '\t%s\n' "-v, --version: Prints version" diff --git a/bin/argbash-init b/bin/argbash-init index 8294208..2966d77 100755 --- a/bin/argbash-init +++ b/bin/argbash-init @@ -66,7 +66,7 @@ _arg_mode="default" print_help() { printf '%s\n' "Make a template for scripts." - printf 'Usage: %s [-s|--separate] [--(no-)hints] [--pos ] [--opt ] [--opt-bool ] [-m|--mode ] [-v|--version] [-h|--help] []\n' "$0" + printf 'Usage: %s [-s|--separate] [--(no-)hints] [--pos ] [--opt ] [--opt-bool ] [-m|--mode ] [-v|--version] [-h|--help] []\n' "$(basename "$0")" printf '\t%s\n' ": Name of the output template (default: '-')" printf '\t%s\n' "-s, --separate: Separate the parsing logic (specify two times for complete separation)" printf '\t%s\n' "--hints, --no-hints: Whether to write hints to the script template (off by default)" diff --git a/src/stuff.m4 b/src/stuff.m4 index 68dbc0c..e47b614 100644 --- a/src/stuff.m4 +++ b/src/stuff.m4 @@ -417,7 +417,7 @@ m4_define([_MAKE_HELP], [MAKE_FUNCTION( [dnl If we have optionals, display them like [--opt1 arg] [--(no-)opt2] ... according to their type. @<:@ becomes square bracket at the end of processing ], [_MAKE_HELP_SYNOPSIS([$1])], - [\n' "@S|@0"_ENDL_()], + [\n' "$(basename "@S|@0")"_ENDL_()], [_IF_HAVE_POSITIONAL_ARGS([_MAKE_HELP_FUNCTION_POSITIONAL_PART])], [dnl If we have 0 optional args, don't do anything (FOR loop would assert, 0 < 1) ], From aae65fbeabd8ed9e6311ab8f412d45f3ea5bf2b4 Mon Sep 17 00:00:00 2001 From: Hannes Leutloff Date: Sat, 21 Jun 2025 15:02:35 +0200 Subject: [PATCH 2/3] Add Hannes Leutloff to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 012feca..c5448df 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,4 @@ Kevin Stravers Matěj Týč Nicola Lunghi Stephen Gallagher +Hannes Leutloff From 048bc4627054049f18b39f4323025b6eeefb9692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= Date: Thu, 17 Jul 2025 23:21:17 +0200 Subject: [PATCH 3/3] Add tests for the new script name in help --- tests/regressiontests/Makefile | 2 ++ tests/regressiontests/make/tests/tests-base.m4 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/regressiontests/Makefile b/tests/regressiontests/Makefile index a640d53..e30db7a 100644 --- a/tests/regressiontests/Makefile +++ b/tests/regressiontests/Makefile @@ -266,6 +266,7 @@ basic: $(TESTDIR)/basic.sh grep -q "local _key$$" $< $< -h | grep -q 'P percent: %' $< -h | grep -q 'O percent: %' + $< -h | grep -q 'Usage: $(notdir $<) ' ! $< -h | grep -qe '\[--\]' test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic.sh" basic-dash: $(TESTDIR)/basic-dash.sh @@ -275,6 +276,7 @@ basic-dash: $(TESTDIR)/basic-dash.sh $< LOO -b | grep -q BOOL=off, $< -h | grep -q 'P percent: %' $< -h | grep -q 'O percent: %' + $< -h | grep -q 'Usage: $(notdir $<) ' $< -h | grep -qe '\[--\]' test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic-dash.sh" test-void: $(TESTDIR)/test-void.sh diff --git a/tests/regressiontests/make/tests/tests-base.m4 b/tests/regressiontests/make/tests/tests-base.m4 index a5c00b2..26e34d7 100644 --- a/tests/regressiontests/make/tests/tests-base.m4 +++ b/tests/regressiontests/make/tests/tests-base.m4 @@ -9,6 +9,7 @@ ADD_TEST_BASH([basic], [[ grep -q "local _key$$" $< $< -h | grep -q 'P percent: %' $< -h | grep -q 'O percent: %' + $< -h | grep -q 'Usage: $(notdir $<) ' ! $< -h | grep -qe '\[--\]' ]]) @@ -20,6 +21,7 @@ ADD_TEST_DASH([basic], [[ $< LOO -b | grep -q BOOL=off, $< -h | grep -q 'P percent: %' $< -h | grep -q 'O percent: %' + $< -h | grep -q 'Usage: $(notdir $<) ' $< -h | grep -qe '\[--\]' ]])