Skip to content

Commit b45b24c

Browse files
authored
Merge pull request #221 from cisagov/improvement/adjust_gnu_getopt_check_logic
Adjust the logic used to check for GNU getopt in the `setup-env` script
2 parents ad43910 + 03065cd commit b45b24c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

setup-env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ LONGOPTS="force,help,install-hooks,list-versions,python-version:,venv-name:"
101101
# Define short options for getopt
102102
SHORTOPTS="fhilp:v:"
103103

104-
# Check for GNU getopt by matching a specific pattern ("getopt from util-linux")
105-
# in its version output. This approach presumes the output format remains stable.
106-
# Be aware that format changes could invalidate this check.
107-
if [[ $(getopt --version 2> /dev/null) != *"getopt from util-linux"* ]]; then
104+
# Check for GNU getopt by testing for long option support. GNU getopt supports
105+
# the "--test" option and will return exit code 4 while POSIX/BSD getopt does
106+
# not and will return exit code 0.
107+
if getopt --test > /dev/null 2>&1; then
108108
cat << 'END_OF_LINE'
109109
110110
Please note, this script requires GNU getopt due to its enhanced

0 commit comments

Comments
 (0)