summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-08-30 17:50:10 +0200
committertv <tv@krebsco.de>2017-08-30 17:50:10 +0200
commit607199cc67f143387d34e43851b9031082dfd29c (patch)
tree9688c901354dc181283f02bb98a47b852162ac7a
parenta84469066c929490803bfcf0fd52e94a8d0a4056 (diff)
use getopt
-rwxr-xr-xdic25
1 files changed, 16 insertions, 9 deletions
diff --git a/dic b/dic
index fb81251..8588998 100755
--- a/dic
+++ b/dic
@@ -1,19 +1,26 @@
#! /bin/sh
-# usage: dic WORD [LANG]
+# usage: dic [--lang=LANG] WORD...
# where LANG may be one of en, fr, es, it, ch, ru, pt, pl
# multiple WORDs may be seperated by + like this: multiple+words
set -euf
main() {
- case $# in
- 1|2) :;; # ok
- *) usage; exit 23;;
- esac
-
- search=$1
- lang=de
- lp=${2-en}de
+ _args=$(getopt -n "$0" -s sh \
+ -o l: \
+ -l lang: \
+ -- "$@")
+ if \test $? != 0; then exit 1; fi
+ eval set -- "$_args"
+ unset _args
+ lang=en
+ while :; do case $1 in
+ -l|--lang) lang=$2; shift 2;;
+ --) shift; break;;
+ esac; done
+
+ search=$*
+ lp=${lang}de
GET | simplify | tac
}