Skip to content

Commit 77021ad

Browse files
committed
correct options processing
1 parent 67bb17a commit 77021ad

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

test_harness/single_node/docker_container_driver.sh

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,59 +21,55 @@ EXPLICIT_WORKDIR=""
2121
INTERACTIVE_OPTION=""
2222
VERBOSITY=0
2323

24-
# Options in force:
25-
26-
# -V (extra verbosity). Prints out useful stuff including VERSION information
27-
# -u USERNAME run test in container as this USERNAME
28-
29-
# Options currently used for troubleshooting only:
30-
31-
# -i invoke container with -i and -t
32-
# -c verbosely prints the container name
33-
# -L leaks the container (i.e. does not kill it after the test run)
34-
# -p "/path/value" sets the IRODS_CONTROL_PATH for changing where iRODS server control scripts are looked for
35-
# -r "remove_option_value" (default: "--rm") may be used to suppress ("") automatic removal of container when stopped
36-
# -w "explicit_workdir" specify a work directory when running the test
24+
usage() {
25+
echo "Usage:
26+
$0 [options] /external/path/to/script"
27+
28+
echo 'Options :
29+
-V (extra verbosity). Prints out useful stuff including VERSION information
30+
-u USERNAME run test in container as this USERNAME
31+
-i invoke container with -i and -t
32+
-c verbosely prints the container name
33+
-L leaks the container (i.e. does not kill it after the test run)
34+
-p "/path/value" sets the IRODS_CONTROL_PATH for changing where iRODS server control scripts are looked for
35+
-r "remove_option_value" (default: "--rm") may be used to suppress ("") automatic removal of container when stopped
36+
-w "explicit_workdir" specify a work directory when running the test
37+
'
38+
exit 2
39+
}
3740

3841
while [[ $1 = -* ]]; do
3942
if [ "$1" = -i ]; then
4043
INTERACTIVE_OPTION="-it"
4144
shift
42-
fi
43-
if [ "$1" = -V ]; then
45+
elif [ "$1" = -V ]; then
4446
VERBOSITY=1
4547
shift
46-
fi
47-
if [ "$1" = -c ]; then
48+
elif [ "$1" = -c ]; then
4849
ECHO_CONTAINER=1
4950
shift
50-
fi
51-
if [ "$1" = -L ]; then
51+
elif [ "$1" = -L ]; then
5252
KILL_TEST_CONTAINER=0
5353
shift
54-
fi
55-
if [ "$1" = -p ]; then
54+
elif [ "$1" = -p ]; then
5655
IRODS_CONTROL_PATH="$2"
5756
shift 2
58-
fi
59-
if [ "$1" = -u ]; then
57+
elif [ "$1" = -u ]; then
6058
RUN_AS_USER="$2"
6159
shift 2
62-
fi
63-
if [ "$1" = -r ]; then
60+
elif [ "$1" = -r ]; then
6461
REMOVE_OPTION="$2"
6562
shift 2
66-
fi
67-
if [ "$1" = -w ]; then
63+
elif [ "$1" = -w ]; then
6864
EXPLICIT_WORKDIR="$2"
6965
shift 2
66+
else
67+
usage
7068
fi
7169
done
7270

7371
if [ "$1" = "" ]; then
74-
echo >&2 "Usage: $0 [options] /path/to/script"
75-
echo >&2 "With options: [-L] to leak, [-u username] to run as non-root user"
76-
exit 1
72+
usage
7773
fi
7874

7975
DIR=$(dirname "$0")

0 commit comments

Comments
 (0)