GIT.Harvie.CZ
/
mirrors
/
Programs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bb49446
)
better getopts
author
Tomas Mudrunka
<tomas@mudrunka.cz>
Fri, 5 Aug 2016 20:01:10 +0000
(22:01 +0200)
committer
Tomas Mudrunka
<tomas@mudrunka.cz>
Fri, 5 Aug 2016 20:01:10 +0000
(22:01 +0200)
bash/getopts.sh
patch
|
blob
|
blame
|
history
diff --git
a/bash/getopts.sh
b/bash/getopts.sh
index 270410ae89dac1d7f1c07c8c70d0c6e709572b60..f65d50ba73ec76dd298d1cafef8f84e31f364092 100755
(executable)
--- a/
bash/getopts.sh
+++ b/
bash/getopts.sh
@@
-1,7
+1,18
@@
#!/bin/sh
-while getopts "
a:b:c:d:
" OPT; do
+while getopts "
:a:b:c:d:f
" OPT; do
echo "$OPT ==> $OPTARG";
+ case $OPT in
+ a ) ahoj=$OPTARG;;
+
+ '?') echo "Unknown option: -$OPTARG" >&2; exit 1;;
+ ':') echo "Missing option argument for -$OPTARG" >&2; exit 2;;
+ * ) echo "Unimplemented option: -$OPT" >&2; exit 3;;
+ esac
done
+echo
shift $(($OPTIND -1)); echo "Rest: $@";
+
+: ${ahoj:=default}
+echo ahoj: $ahoj
This page took
0.187389 seconds
and
4
git commands to generate.