Skip to content

Commit 7892c4a

Browse files
committed
feat: getopts for -h option
1 parent 6f283c6 commit 7892c4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

conda/install.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,31 @@ else
2222
fi
2323

2424

25+
usage(){
26+
echo "Usage: install.sh [-h]"
27+
echo
28+
echo "-h : show this help"
29+
exit 1
30+
}
31+
32+
while getopts "h" OPTNAME ; do
33+
case "${OPTNAME}" in
34+
h)
35+
usage
36+
;;
37+
:)
38+
# If expected argument omitted:
39+
echo "Error: -${OPTARG} requires an argument."
40+
exit 1
41+
;;
42+
*)
43+
# If unknown (any other) option:
44+
echo "Error: -${OPTARG} unknown."
45+
exit 1
46+
;;
47+
esac
48+
done
49+
2550
# note:
2651
# this is a portable way (works in linux and osx) to get the directory of this script.
2752
# readlink -ef may not work on osx.

0 commit comments

Comments
 (0)