Skip to content

Commit 1dbae2d

Browse files
committed
[fix] : Changed to getopts for correct interpretation
1 parent 07e9b7b commit 1dbae2d

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

tools/msg.sh

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,54 +25,44 @@ _help() {
2525
echo " debug Debug message"
2626
echo
2727
echo " General options:"
28-
echo " -a | --appname [name] Specify the app name"
28+
echo " -a Specify the app name"
2929
echo " -n | --nocolor No output colored output"
30-
echo " -o | --echo-opts [opts] Specify echo options"
30+
echo " -o Specify echo options"
3131
echo " -x | --bash-debug Enables output bash debugging"
3232
echo " -h | --help This help message"
3333
}
3434

35-
# Parse options
36-
ARGUMENT="${@}"
37-
_opt_short="a:no:xh"
38-
_opt_long="appname:,nocolor,echo-opts:,bash-debug,help"
39-
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
40-
[[ ${?} != 0 ]] && exit 1
4135

42-
eval set -- "${OPT}"
43-
unset OPT _opt_short _opt_long
44-
45-
while true; do
46-
case ${1} in
47-
-a | --appname)
48-
appname="${2}"
49-
shift 2
50-
;;
51-
-n | --nocolor)
52-
nocolor=true
53-
shift 1
54-
;;
55-
-o | --echo-opts)
56-
echo_opts="${2}"
57-
shift 2
58-
;;
59-
-x | --bash-debug)
36+
while getopts "a:no:xh-:" arg; do
37+
case ${arg} in
38+
a) appname="${OPTARG}" ;;
39+
n) nocolor=true ;;
40+
o) echo_opts="${OPTARG}" ;;
41+
x)
6042
bash_debug=true
6143
set -xv
62-
shift 1
6344
;;
64-
-h | --help)
45+
h)
6546
_help
6647
exit 0
6748
;;
68-
--)
69-
shift 1
70-
break
71-
;;
72-
73-
esac
49+
-)
50+
case "${OPTARG}" in
51+
"nocolor") nocolor=true ;;
52+
"bash-debug")
53+
bash_debug=true
54+
set -xv
55+
;;
56+
"help")
57+
_help
58+
exit 0
59+
;;
60+
esac
61+
esac
7462
done
7563

64+
shift $((OPTIND - 1))
65+
7666
# Color echo
7767
#
7868
# Text Color

0 commit comments

Comments
 (0)