Skip to content

Allow checking whether optionals provided explicitly #187

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 4 commits into from
May 11, 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
@@ -1,5 +1,6 @@
Bianca Tamayo <hi@biancatamayo.me>
Conduitry <git@chor.date>
Felipe Santos
Kevin Stravers <kevin@stravers.net>
Matěj Týč <matej.tyc@gmail.com>
Stephen Gallagher <sgallagh@redhat.com>
4 changes: 2 additions & 2 deletions bin/argbash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2016,SC2059
# SC2016: Expressions don't expand in single quotes, use double quotes for that.
Expand Down Expand Up @@ -495,7 +495,7 @@ then
# match against suspicious, then inverse match against correct stuff:
# #<optional whitespace>\(allowed\|another allowed\|...\)<optional whitespace><opening bracket <or> end of line>
# Then, extract all matches (assumed to be alnum chars + '_') from grep and put them in the error msg.
grep_output="$(printf "%s" "$output" | grep '^#\s*\(ARG_\|ARGBASH\)' | grep -v '^#\s*\(ARGBASH_SET_INDENT\|ARG_OPTIONAL_SINGLE\|ARG_VERSION\|ARG_VERSION_AUTO\|ARG_HELP\|ARG_OPTIONAL_INCREMENTAL\|ARG_OPTIONAL_REPEATED\|ARG_VERBOSE\|ARG_OPTIONAL_BOOLEAN\|ARG_OPTIONAL_ACTION\|ARG_POSITIONAL_SINGLE\|ARG_POSITIONAL_INF\|ARG_POSITIONAL_MULTI\|ARG_POSITIONAL_DOUBLEDASH\|ARG_OPTION_STACKING\|ARG_RESTRICT_VALUES\|ARG_DEFAULTS_POS\|ARG_LEFTOVERS\|ARGBASH_WRAP\|INCLUDE_PARSING_CODE\|DEFINE_LOAD_LIBRARY\|DEFINE_SCRIPT_DIR\|DEFINE_SCRIPT_DIR_GNU\|ARGBASH_SET_DELIM\|ARGBASH_GO\|ARGBASH_PREPARE\|ARG_TYPE_GROUP\|ARG_TYPE_GROUP_SET\|ARG_USE_ENV\|ARG_USE_PROGRAM\)\s*\((\|$\)' | sed -e 's/#\s*\([[:alnum:]_]*\).*/\1 /' | tr -d '\n\r')"
grep_output="$(printf "%s" "$output" | grep '^#\s*\(ARG_\|ARGBASH\)' | grep -v '^#\s*\(ARGBASH_SET_INDENT\|ARG_OPTIONAL_SINGLE\|ARG_VERSION\|ARG_VERSION_AUTO\|ARG_HELP\|ARG_OPTIONAL_INCREMENTAL\|ARG_OPTIONAL_REPEATED\|ARG_VERBOSE\|ARG_OPTIONAL_BOOLEAN\|ARG_OPTIONAL_ACTION\|ARG_POSITIONAL_SINGLE\|ARG_POSITIONAL_INF\|ARG_POSITIONAL_MULTI\|ARG_POSITIONAL_DOUBLEDASH\|ARGBASH_INDICATE_SUPPLIED\|ARG_OPTION_STACKING\|ARG_RESTRICT_VALUES\|ARG_DEFAULTS_POS\|ARG_LEFTOVERS\|ARGBASH_WRAP\|INCLUDE_PARSING_CODE\|DEFINE_LOAD_LIBRARY\|DEFINE_SCRIPT_DIR\|DEFINE_SCRIPT_DIR_GNU\|ARGBASH_SET_DELIM\|ARGBASH_GO\|ARGBASH_PREPARE\|ARG_TYPE_GROUP\|ARG_TYPE_GROUP_SET\|ARG_USE_ENV\|ARG_USE_PROGRAM\)\s*\((\|$\)' | sed -e 's/#\s*\([[:alnum:]_]*\).*/\1 /' | tr -d '\n\r')"
test -n "$grep_output" && die "Your script contains possible misspelled Argbash macros: $grep_output" 1
fi
if test "$outfname" != '-'
Expand Down
2 changes: 1 addition & 1 deletion bin/argbash-1to2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2016
# SC2016: Expressions don't expand in single quotes, use double quotes for that.
Expand Down
4 changes: 2 additions & 2 deletions bin/argbash-init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2001,SC2016
# SC2001: See if you can use ${variable//search/replace} instead.
Expand Down Expand Up @@ -277,7 +277,7 @@ positional_argument()

do_header()
{
echo "#!/bin/bash"
echo "#!/usr/bin/env bash"
echo
# We if separate == 2, we don't want to pass this to argbash at all
test "$_arg_separate" = 2 && test "$1" = "script" && echo "# Created by argbash-init v$version" && return
Expand Down
9 changes: 9 additions & 0 deletions doc/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@ Special arguments
A use case for this is wrapping of scripts that are completely ``Argbash``-agnostic.
Therefore, your script can take its own arguments and the rest that is not recognized can go to the wrapped script.

* Detect supplied arguments:
::

ARGBASH_INDICATE_SUPPLIED([long opt arg name], [another long opt arg name (optional)], ...)

This macro takes a list of long optional argument names and will generate a variable for each optional that will be set if that argument was explicitly provided on the command line. This only works for optional arguments.

For example, if you have `ARG_OPTIONAL_BOOLEAN([quiet], , , [off])`, followed by `ARGBASH_INDICATE_SUPPLIED([quiet])`, then if `--quiet` was provided on the command line the variable `_supplied_arg_quiet=1` would be set. This allows you to see if an argument was explicitly provided using `[ "$_supplied_arg_quiet" = 1 ]`. If the argument was not passed to the program then this variable will be set to `0`.

Typing macros
+++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ Imagine that you want to download an example, edit it, and make it a full-fledge
You obviously have to fire up `docker`, but then, you just create the one-liner, download the example, and proceed.

``` shell
printf '%s\n' '#!/bin/bash' 'docker run --rm -v "$(pwd):/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-docker
printf '%s\n' '#!/bin/bash' 'docker run --rm -e PROGRAM=argbash-init -v "$(pwd):/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-init-docker
printf '%s\n' '#!/usr/bin/env bash' 'docker run --rm -v "$(pwd):/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-docker
printf '%s\n' '#!/usr/bin/env bash' 'docker run --rm -e PROGRAM=argbash-init -v "$(pwd):/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-init-docker
chmod a+x argbash-docker argbash-init-docker

./argbash-init-docker --pos positional-arg --opt optional-arg minimal.m4
Expand Down
2 changes: 1 addition & 1 deletion resources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ develop: $(ARGBASH_TO)
@echo Installing to prefix "'/$(PREFIX)' of root $(ROOT)"
mkdir -p "$(ROOT)/$(PREFIX)/bin"
touch "$(ROOT)/$(PREFIX)/bin/argbash" && rm "$(ROOT)/$(PREFIX)/bin/argbash"
echo '#!/bin/bash' > "$(ROOT)/$(PREFIX)/bin/argbash"
echo '#!/usr/bin/env bash' > "$(ROOT)/$(PREFIX)/bin/argbash"
echo '$(abspath $(ROOT_DIR)/$(GENPARSE)) "$$@"' >> "$(ROOT)/$(PREFIX)/bin/argbash"
chmod a+x "$(ROOT)/$(PREFIX)/bin/argbash"
test -z "$(ARGBASH_TO)" || ln -s $(abspath $(ARGBASH_TO)) "$(ROOT)/$(PREFIX)/bin"
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/minimal-raw.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# m4_ignore(
echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/minimal.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# m4_ignore(
echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-parsing.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([filename])
# ARG_OPTIONAL_SINGLE([unit], u, [What unit we accept (b for bytes, k for kibibytes, M for mebibytes)], b)
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-parsing.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([filename])
# ARG_OPTIONAL_SINGLE([unit],[u],[What unit we accept (b for bytes, k for kibibytes, M for mebibytes)],[b])
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-standalone.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([filename])
# ARG_OPTIONAL_SINGLE([unit], u, [What unit we accept (b for bytes, k for kilobytes, M for megabytes)], b)
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-standalone.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([filename])
# ARG_OPTIONAL_SINGLE([unit],[u],[What unit we accept (b for bytes, k for kilobytes, M for megabytes)],[b])
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-wrapper.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DEFINE_SCRIPT_DIR
# ARG_POSITIONAL_INF([directory], [Directories to go through], 1)
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DEFINE_SCRIPT_DIR()
# ARG_POSITIONAL_INF([directory],[Directories to go through],[1])
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DEFINE_SCRIPT_DIR()
# INCLUDE_PARSING_CODE([simple-parsing.sh])
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/simple.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DEFINE_SCRIPT_DIR([])
# INCLUDE_PARSING_CODE([simple-parsing.sh])
Expand Down
2 changes: 1 addition & 1 deletion src/argbash-1to2.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2016
# SC2016: Expressions don't expand in single quotes, use double quotes for that.
Expand Down
4 changes: 2 additions & 2 deletions src/argbash-init.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2001,SC2016
# SC2001: See if you can use ${variable//search/replace} instead.
Expand Down Expand Up @@ -91,7 +91,7 @@ positional_argument()

do_header()
{
echo "#!/bin/bash"
echo "#!/usr/bin/env bash"
echo
# We if separate == 2, we don't want to pass this to argbash at all
test "$_arg_separate" = 2 && test "$1" = "script" && echo "# Created by argbash-init v$version" && return
Expand Down
2 changes: 1 addition & 1 deletion src/argbash.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2016,SC2059
# SC2016: Expressions don't expand in single quotes, use double quotes for that.
Expand Down
12 changes: 12 additions & 0 deletions src/collectors.m4
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ m4_define([__ADD_OPTIONAL_ARGUMENT], [m4_do(
[_FILL_IN_VALUES_FOR_AN_OPTIONAL_ARGUMENT([$1], [$3], _arg_varname, [$5], [$2], [$4])],
[m4_popdef([_arg_varname])],
[m4_define([_DISTINCT_OPTIONAL_ARGS_COUNT], m4_incr(_DISTINCT_OPTIONAL_ARGS_COUNT))],
[m4_case([$5],
[arg], [m4_set_add([_ALL_OPTIONAL_ARGUMENTS], [$1])],
[bool], [m4_set_add([_ALL_OPTIONAL_ARGUMENTS], [$1])],
[dnl]
)],
)])


Expand Down Expand Up @@ -525,6 +530,13 @@ m4_define([_ARG_POSITIONAL_DOUBLEDASH], [m4_do(
)])


argbash_api([ARGBASH_INDICATE_SUPPLIED], _CHECK_PASSED_ARGS_COUNT(1)[m4_do(
[[$0($@)]],
[m4_set_add_all([HAVE_SUPPLIED], $@)],
[CHECK_SUPPLIED_ARE_OPTIONAL([HAVE_SUPPLIED], [_ALL_OPTIONAL_ARGUMENTS], [FATAL_NON_OPTIONAL_SUPPLIED])],
)])


dnl
dnl $1: The mode of argument grouping: One of 'none', 'getopts'
argbash_api([ARG_OPTION_STACKING], _CHECK_PASSED_ARGS_COUNT(1)[m4_do(
Expand Down
2 changes: 1 addition & 1 deletion src/output-completion.m4
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ m4_define([ARGBASH_GO_BASE], [m4_do(
[m4_define([_BASENAME], INFERRED_BASENAME_NOERROR)],
[m4_define([_PROGRAM_NAME], m4_dquote(_BASENAME))],
[m4_define([_FUNCTION_NAME], m4_dquote(_[]_TRANSLATE_BAD_CHARS(_PROGRAM_NAME)))],
[[#!/bin/bash]_ENDL_(2)],
[[#!/usr/bin/env bash]_ENDL_(2)],
[[# Put this file to /etc/bash_completion.d/]_BASENAME()_ENDL_()],
[[# needed because of Argbash --> m4_ignore@{:@@<:@]_ENDL_()],
[_ARGBASH_ID()_ENDL_()],
Expand Down
15 changes: 15 additions & 0 deletions src/stuff.m4
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ dnl $5: Where to get the last value (optional)
m4_define([_VAL_OPT_ADD_SPACE_WITHOUT_GETOPT_OR_SHORT_OPT], [_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[test $[]# -lt 2 && die "Missing value for the optional argument '$_key'." 1],
[$3([$1], ["@S|@2"], [$4])],
[_INDICATION_OF_SUPPLY([$1], [$4])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_SPACE([$4], [m4_default_quoted([$5], [@S|@2])])],
[shift],
)])
Expand All @@ -458,6 +459,7 @@ dnl $5: Where to get the last value (optional)
m4_define([_VAL_OPT_ADD_GETOPTS], [_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[test "$OPTARG" = "" && die "Missing value for the optional argument '-$_key'." 1],
[$3([$1], ["$OPTARG"], [$4])],
[_INDICATION_OF_SUPPLY([$1], [$3])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_SPACE([$4], [m4_default_quoted([$5], [$OPTARG])])],
)])

Expand All @@ -470,6 +472,7 @@ dnl $4: The name of the argument-holding variable
dnl $5: Where to get the last value (optional)
m4_define([_VAL_OPT_ADD_EQUALS_WITH_LONG_OPT], [_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[$3([$1], ["${_key##--$1=}"], [$4])],
[_INDICATION_OF_SUPPLY([$1], [$4])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_EQUALS([$4])],
)])

Expand All @@ -482,6 +485,7 @@ dnl $4: The name of the argument-holding variable
dnl $5: Where to get the last value (optional)
m4_define([_VAL_OPT_ADD_ONLY_WITH_SHORT_OPT_GETOPT], [_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[$3([$1], ["${_key##-$2}"], [$4])],
[_INDICATION_OF_SUPPLY([$1], [$4])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_GETOPT([$4])],
)])

Expand Down Expand Up @@ -522,6 +526,13 @@ m4_define([_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_EQUALS], [m4_do(
)])


dnl
dnl $1: The name of the option arg
dnl $2: The name of the argument-holding variable
m4_define([_INDICATION_OF_SUPPLY], [m4_do(
[m4_set_contains([HAVE_SUPPLIED], [$1], [_supplied$2=1], [])],
)])

m4_define([_MAKE_SEE_ALSO_OPTION_PHRASE], [m4_do(
[[See the comment of option '$1' to see what's going on here - principle is the same.]],
)])
Expand Down Expand Up @@ -731,6 +742,7 @@ m4_define([_MAKE_OPTARG_SIMPLE_CASE_SECTION], [m4_do(
[bool],
[_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[[$5="on"]],
[_INDICATION_OF_SUPPLY([$1], [$5])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_SPACE([$5])],
[[test "${1:0:5}" = "--no-" && $5="off"]],
)],
Expand Down Expand Up @@ -763,6 +775,7 @@ m4_define([_MAKE_OPTARG_GETOPTS_CASE_SECTION], [m4_do(
[bool],
[_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[[$5="on"]],
[_INDICATION_OF_SUPPLY([$1], [$5])],
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_SPACE([$5])],
)],
[incr],
Expand Down Expand Up @@ -823,6 +836,7 @@ m4_define([_MAKE_OPTARG_GETOPT_CASE_SECTION], [m4_do(
[bool],
[_JOIN_INDENTED(_INDENT_LEVEL_IN_ARGV_CASE_BODY,
[[$5="on"]],
[_INDICATION_OF_SUPPLY([$1], [$5])],
_PASS_WHEN_GETOPT([$2]),
[_APPEND_WRAPPED_ARGUMENT_TO_ARRAY_SPACE([$5])],
)],
Expand Down Expand Up @@ -1234,6 +1248,7 @@ m4_define([_MAKE_DEFAULTS_OPTIONAL], [m4_do(
[incr], [_arg_varname=m4_expand(_default)_ENDL_],
[repeated], [_arg_varname=(_default)_ENDL_],
[_arg_varname=_sh_quote(_default)_ENDL_])],
[m4_set_contains([HAVE_SUPPLIED], _argname, [[_supplied]_arg_varname=0]_ENDL_, [])],
)])],
)])

Expand Down
17 changes: 17 additions & 0 deletions src/utilities.m4
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,20 @@ m4_define([UNDERLINE], [m4_do(
[m4_if(m4_len([$1]), 0, ,
[m4_for(idx, 1, m4_len([$1]), 1, [$2])])],
)])


dnl
dnl $1: Set of arguments marked as supplied
dnl $2: Set of all optional arguments
dnl $3: Macro that gets called with the supplied arguments that are not optional, if any.
m4_define([CHECK_SUPPLIED_ARE_OPTIONAL], [m4_do(
[m4_set_add_all([_temp_supplied_not_optional]m4_set_difference([$1], [$2]))],
[m4_if(m4_set_size([_temp_supplied_not_optional]), 0,
[],
[$3([_temp_supplied_not_optional])])],
[m4_set_delete([_temp_set_supplied])],
)])


m4_define([FATAL_NON_OPTIONAL_SUPPLIED],
[m4_fatal([ARGBASH_INDICATE_SUPPLIED: The following arguments are not optional:] m4_set_dump([$1], [, ]))])
19 changes: 13 additions & 6 deletions tests/regressiontests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ARGBASH_INIT_EXEC ?= $(ARGBASH_INIT)

%-dash.sh: %.m4 $(ARGBASH_BIN)
$(word 2,$^) --type posix-script -o $@ $<
sed -i "s|#!/bin/bash|#!$(shell which dash)|" $@
sed -i "s|#!/usr/bin/env bash|#!$(shell which dash)|" $@

%.sh: %.m4 $(ARGBASH_BIN)
$(word 2,$^) $< -o $@
Expand Down Expand Up @@ -126,6 +126,7 @@ TESTS_GEN += \
gen-test-bool-default \
gen-test-pos-opt \
gen-test-pos-opt2 \
gen-test-supplied-non-optional \
gen-test-more \
gen-test-illegal-pos \
gen-test-illegal-opt \
Expand Down Expand Up @@ -372,6 +373,9 @@ test-simple: $(TESTDIR)/test-simple.sh
ERROR="[Nn]ot enough" $(REVERSE) $<
ERROR="require exactly 1" $(REVERSE) $<
$< pos -o 'uf ta' | grep -q 'OPT_S=uf ta,POS_S=pos,'
$< pos -o 'uf ta' --print-optionals | grep -q '_supplied_arg_prefix=1,_supplied_arg_print_optionals=1,_supplied_arg_la=0,_supplied_arg_not_supplied=x'
$< pos -o 'uf ta' --print-optionals --la x | grep -q '_supplied_arg_prefix=1,_supplied_arg_print_optionals=1,_supplied_arg_la=1,_supplied_arg_not_supplied=x'
$< pos -o 'uf ta' --print-optionals --la x --not-supplied | grep -q '_supplied_arg_prefix=1,_supplied_arg_print_optionals=1,_supplied_arg_la=1,_supplied_arg_not_supplied=x'
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/test-simple.sh"
test-simple-dash: $(TESTDIR)/test-simple-dash.sh
$< pos | grep -q 'OPT_S=x,POS_S=pos,'
Expand Down Expand Up @@ -558,6 +562,9 @@ gen-test-pos-opt: $(TESTDIR)/gen-test-pos-opt.m4 $(ARGBASH_BIN)
gen-test-pos-opt2: $(TESTDIR)/gen-test-pos-opt2.m4 $(ARGBASH_BIN)
ERROR="same_arg" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null

gen-test-supplied-non-optional: $(TESTDIR)/gen-test-supplied-non-optional.m4 $(ARGBASH_BIN)
ERROR="ARGBASH_INDICATE_SUPPLIED: The following arguments are not optional: phantom, pos-arg-inf, pos-arg-multi, pos-arg-single, opt-arg-action, opt-arg-incr, opt-arg-repeat" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null

gen-test-more: $(TESTDIR)/gen-test-more.m4 $(ARGBASH_BIN)
ERROR="is unknown" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null

Expand Down Expand Up @@ -741,9 +748,9 @@ gen-test-group-wrong: $(TESTDIR)/gen-test-group-wrong.m4 $(ARGBASH_BIN)
ERROR="'foo' is not a script argument" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null

$(TESTDIR)/test-semi_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
printf "%s\n%s\n" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
$(TESTDIR)/test-very_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
printf "%s\n%s\n" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
test-semi_strict: $(TESTDIR)/test-semi_strict.sh
$< -o -x pos-arg | grep -q 'OPT_S=-x,'
$< -o --opt-argx pos-arg | grep -q 'OPT_S=--opt-argx,'
Expand All @@ -758,11 +765,11 @@ test-very_strict: $(TESTDIR)/test-very_strict.sh
ERROR="are trying to pass an option" $(REVERSE) $< --foobar
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/test-very_strict.sh"
$(TESTDIR)/test-getopt-equals.sh: $(TESTDIR)/test-onlyopt.m4 $(ARGBASH_BIN)
printf "%s\n%s\n%s\n" "#!/bin/bash" "# ARGBASH_SET_DELIM([=])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
printf "%s\n%s\n%s\n" "#!/usr/bin/env bash" "# ARGBASH_SET_DELIM([=])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
$(TESTDIR)/test-getopt-both.sh: $(TESTDIR)/test-onlyopt.m4 $(ARGBASH_BIN)
printf "%s\n%s\n%s\n" "#!/bin/bash" "# ARGBASH_SET_DELIM([ =])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
printf "%s\n%s\n%s\n" "#!/usr/bin/env bash" "# ARGBASH_SET_DELIM([ =])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
$(TESTDIR)/test-getopt-space.sh: $(TESTDIR)/test-onlyopt.m4 $(ARGBASH_BIN)
printf "%s\n%s\n%s\n" "#!/bin/bash" "# ARGBASH_SET_DELIM([ ])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
printf "%s\n%s\n%s\n" "#!/usr/bin/env bash" "# ARGBASH_SET_DELIM([ ])" "# ARG_OPTION_STACKING([getopt])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
test-getopt-both: $(TESTDIR)/test-getopt-both.sh
$< -ii | grep -q 'OPT_INCR=4,'
$< --incrx -ii | grep -q 'OPT_INCR=5,'
Expand Down
2 changes: 1 addition & 1 deletion tests/regressiontests/basic.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion tests/regressiontests/call-salone.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck source=OUTPUT_ABS_DIRNAME/test-salone.sh

Expand Down
2 changes: 1 addition & 1 deletion tests/regressiontests/gen-test-bool-default.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_OPTIONAL_BOOLEAN([feature], f, [Turn the feature on], [true])
# ARGBASH_GO
2 changes: 1 addition & 1 deletion tests/regressiontests/gen-test-illegal-opt.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_OPTIONAL_SINGLE([opt-arg], [the badly placed help message])
# ARGBASH_GO
Expand Down
2 changes: 1 addition & 1 deletion tests/regressiontests/gen-test-illegal-pos.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([pos=arg], [@pos-arg@], [default])
# ARGBASH_GO
Expand Down
2 changes: 1 addition & 1 deletion tests/regressiontests/gen-test-infinity-illegal.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# ARG_POSITIONAL_SINGLE([pos-arg], [@pos-arg@], [default_value])
# ARG_POSITIONAL_INF([pos-arg], [@pos-arg@], 0, first, second, third)
Expand Down
Loading
Loading