Skip to content

Commit ba5e2fb

Browse files
committed
fixing up usage so its a function
1 parent 7328c89 commit ba5e2fb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docker2singularity.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
set -o errexit
3737
set -o nounset
3838

39-
usage="USAGE: docker2singularity [-m \"/mount_point1 /mount_point2\"] [options] docker_image_name"
39+
function usage() {
4040

41-
# --- Option processing --------------------------------------------
42-
if [ $# == 0 ] ; then
43-
echo "${usage}"
41+
echo "USAGE: docker2singularity [-m \"/mount_point1 /mount_point2\"] [options] docker_image_name"
42+
echo ""
4443
echo "OPTIONS:
4544
4645
Image Format
@@ -51,7 +50,11 @@ if [ $# == 0 ] ; then
5150
--mount -m provide list of custom mount points (in quotes!)
5251
--help -h show this help and exit
5352
"
53+
}
5454

55+
# --- Option processing --------------------------------------------
56+
if [ $# == 0 ] ; then
57+
usage
5558
exit 1;
5659
fi
5760

@@ -62,7 +65,8 @@ new_container_name=""
6265
while true; do
6366
case ${1:-} in
6467
-h|--help|help)
65-
echo "${usage}"
68+
usage
69+
usage
6670
exit 0
6771
;;
6872
-n|--name)
@@ -86,16 +90,16 @@ while true; do
8690
shift
8791
;;
8892
:) printf "missing argument for -%s\n" "$option" >&2
89-
echo "$usage" >&2
93+
usage
9094
exit 1
9195
;;
9296
\?) printf "illegal option: -%s\n" "$option" >&2
93-
echo "$usage" >&2
97+
usage
9498
exit 1
9599
;;
96100
-*)
97101
printf "illegal option: -%s\n" "$option" >&2
98-
echo "$usage" >&2
102+
usage
99103
exit 1
100104
;;
101105
*)

0 commit comments

Comments
 (0)