Skip to content

Show basename of script in usage text #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Kevin Stravers <[email protected]>
Matěj Týč <[email protected]>
Nicola Lunghi <[email protected]>
Stephen Gallagher <[email protected]>
Hannes Leutloff <[email protected]>
2 changes: 1 addition & 1 deletion bin/argbash
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ _arg_debug=
print_help()
{
printf '%s\n' "Argbash is an argument parser generator for Bash."
printf 'Usage: %s [-o|--output <arg>] [-i|--(no-)in-place] [-t|--type <type>] [--(no-)library] [--strip <content>] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search <arg>] [--debug <arg>] [-h|--help] [-v|--version] <input>\n' "$0"
printf 'Usage: %s [-o|--output <arg>] [-i|--(no-)in-place] [-t|--type <type>] [--(no-)library] [--strip <content>] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search <arg>] [--debug <arg>] [-h|--help] [-v|--version] <input>\n' "$(basename "$0")"
printf '\t%s\n' "<input>: 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)"
Expand Down
2 changes: 1 addition & 1 deletion bin/argbash-1to2
Original file line number Diff line number Diff line change
Expand Up @@ -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 <arg>] [-v|--version] [-h|--help] <input-1> [<input-2>] ... [<input-n>] ...\n' "$0"
printf 'Usage: %s [-o|--output <arg>] [-v|--version] [-h|--help] <input-1> [<input-2>] ... [<input-n>] ...\n' "$(basename "$0")"
printf '\t%s\n' "<input>: 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"
Expand Down
2 changes: 1 addition & 1 deletion bin/argbash-init
Original file line number Diff line number Diff line change
Expand Up @@ -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 <arg>] [--opt <arg>] [--opt-bool <arg>] [-m|--mode <MODE>] [-v|--version] [-h|--help] [<output>]\n' "$0"
printf 'Usage: %s [-s|--separate] [--(no-)hints] [--pos <arg>] [--opt <arg>] [--opt-bool <arg>] [-m|--mode <MODE>] [-v|--version] [-h|--help] [<output>]\n' "$(basename "$0")"
printf '\t%s\n' "<output>: 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)"
Expand Down
2 changes: 1 addition & 1 deletion src/stuff.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
],
Expand Down
2 changes: 2 additions & 0 deletions tests/regressiontests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/regressiontests/make/tests/tests-base.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\[--\]'
]])

Expand All @@ -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 '\[--\]'
]])

Expand Down
Loading