diff options
author | tv <tv@krebsco.de> | 2017-08-30 17:50:10 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2017-08-30 17:50:10 +0200 |
commit | 607199cc67f143387d34e43851b9031082dfd29c (patch) | |
tree | 9688c901354dc181283f02bb98a47b852162ac7a | |
parent | a84469066c929490803bfcf0fd52e94a8d0a4056 (diff) |
use getopt
-rwxr-xr-x | dic | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -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 } |