summary refs log tree commit diff
path: root/bin/up.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-03 01:57:23 -0500
committerJune McEnroe <june@causal.agency>2020-03-03 02:01:41 -0500
commit34d583aaf8ad210bcd6025e819224636c822e1b1 (patch)
tree38a5e8a8564cdb623f71e26df77f73320d8971cb /bin/up.sh
parentStyle %T outside of Rs in italic (diff)
downloadsrc-34d583aaf8ad210bcd6025e819224636c822e1b1.tar.gz
src-34d583aaf8ad210bcd6025e819224636c822e1b1.zip
Use getopts in shell scripts
WTF why did no one tell me about this?
Diffstat (limited to 'bin/up.sh')
-rw-r--r--bin/up.sh15
1 files changed, 7 insertions, 8 deletions
diff --git a/bin/up.sh b/bin/up.sh
index 0ff9e69b..8b70de70 100644
--- a/bin/up.sh
+++ b/bin/up.sh
@@ -58,17 +58,16 @@ uploadTerminal() {
 	upload "${temp}/term.html"
 }
 
-args=$(setopt 'chst' "$@")
-eval set -- "$args"
-for opt; do
+while getopts 'chst' opt; do
 	case "$opt" in
-		(-c) shift; fn=uploadCommand;;
-		(-h) shift; fn=uploadHi;;
-		(-s) shift; fn=uploadScreen;;
-		(-t) shift; fn=uploadTerminal;;
-		(--) shift; break;;
+		(c) fn=uploadCommand;;
+		(h) fn=uploadHi;;
+		(s) fn=uploadScreen;;
+		(t) fn=uploadTerminal;;
+		(?) exit 1;;
 	esac
 done
+shift $(($OPTIND - 1))
 [ $# -eq 0 ] && : ${fn:=uploadText}
 : ${fn:=upload}
 
lspan='3' class='logmsg'> 2017-07-31Add tupJune McEnroe 2017-07-31Use designated initializer for hnel tableJune McEnroe I did not know this syntax worked! 2017-07-30Add juneJune McEnroe 2017-07-30Play nethack as ValkyrieJune McEnroe 2017-07-28Add toggle to hnelJune McEnroe 2017-07-28Install slJune McEnroe 2017-07-25Add up, supJune McEnroe 2017-07-24Autopickup ringsJune McEnroe 2017-07-24Name dogJune McEnroe 2017-07-23Add nethackrcJune McEnroe 2017-07-23Remove useless setuid in briJune McEnroe Don't you think it would be better if the setuid bit only gave you permission to do it and didn't do it for you? 2017-07-23Clean up hnel a tiny bitJune McEnroe 2017-07-21Set window size in hnelJune McEnroe 2017-07-21Add hnelJune McEnroe 2017-07-19chmod 600 in dtchJune McEnroe