Skip to content

Commit acff64b

Browse files
committed
Fix #17: add ARGSPARSE_GNU_GETOPT variable
1 parent 38d3f67 commit acff64b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

argsparse.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ fi
299299
## @showinitializer
300300
declare -r ARGSPARSE_VERSION=1.8
301301

302+
303+
## @var ARGSPARASE_GNU_GETOPT
304+
## @brief the location of the GNU getopt program.
305+
## @details If empty (the default), a PATH lookup will be
306+
## performed. When specified, it should be an absolute-path reference
307+
## as current working directory invariance is not guaranteed.
308+
## @showinitializer
309+
declare ARGSPARSE_GNU_GETOPT=${ARGSPARSE_GNU_GETOPT:-getopt}
310+
311+
302312
# Enable required features
303313
shopt -s extglob
304314
set +o posix
@@ -1710,6 +1720,7 @@ __argsparse_parse_options_valuecheck() {
17101720
return 0
17111721
}
17121722

1723+
17131724
## @fn __argsparse_parse_options_no_usage()
17141725
## @brief Parse options without triggering usage
17151726
__argsparse_parse_options_no_usage() {
@@ -1759,7 +1770,7 @@ __argsparse_parse_options_no_usage() {
17591770
done
17601771

17611772
# 4. Invoke getopt and replace arguments.
1762-
if ! getopt_temp=$(getopt -s bash -n "$argsparse_pgm" \
1773+
if ! getopt_temp=$("${ARGSPARSE_GNU_GETOPT}" -s bash -n "$argsparse_pgm" \
17631774
--longoptions="$longs" "$shorts" "$@")
17641775
then
17651776
# Syntax error on the command implies returning with error.

0 commit comments

Comments
 (0)