Skip to content

Commit

Permalink
docker: make script portable for macOS
Browse files Browse the repository at this point in the history
Problem: recently, several core developers have noted that the
docker-run-checks.sh script borks when command-line options that specify
values do so with an equals sign rather than a space.

This can be fixed by stripping out any '=' before the arguments are
passed to getopt. Since getopt automatically stops at '--' when
parsing command-line options, this should preserve '=' in any options
passed to configure. Additionally, add a help message and option to
defer to the loop for GNU getopt via an environment variable.
  • Loading branch information
wihobbs committed Apr 12, 2024
1 parent 91419b7 commit 7863917
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/test/docker/docker-run-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ die() { echo -e "$prog: $@"; exit 1; }
#
declare -r long_opts="help,quiet,interactive,image:,flux-security-version:,jobs:,no-cache,no-home,distcheck,tag:,build-directory:,install-only,no-poison,recheck,unit-test-only,quick-check,inception,platform:,workdir:,system"
declare -r short_opts="hqIdi:S:j:t:D:Prup:"
declare -r usage="
declare usage="
Usage: $prog [OPTIONS] -- [CONFIGURE_ARGS...]\n\
Build docker image for CI builds, then run tests inside the new\n\
container as the current user and group.\n\
Expand Down Expand Up @@ -59,9 +59,14 @@ Options:\n\
"

# check if running in OSX
if [[ "$(uname)" == "Darwin" ]]; then
if [[ "$(uname)" == "Darwin" ]] && [[ $FORCE_GNU_GETOPT != 1 ]]; then
# BSD getopt
GETOPTS=`getopt $short_opts -- $*`
GETOPTS=`getopt $short_opts -- $(echo $* | sed "s/=/ /g")`
export EXTRA_MACOS_STUFF="\n\
You are using BSD getopt on macOS. It's best to avoid using '=' between options.\n\
If gnu-getopt is first in your PATH, force the script to use that by setting\n\
FORCE_GNU_GETOPT=1.\n"
usage=${usage}${EXTRA_MACOS_STUFF}
else
# GNU getopt
GETOPTS=`getopt -u -o $short_opts -l $long_opts -n $prog -- $@`
Expand Down

0 comments on commit 7863917

Please sign in to comment.