scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 4bb1fd5cafc5c174d907dbcb75a9f65fc8aa8117
parent a41772284db62745e7e39d23e25fed569ccd8789
Author: clamiax <smoppy@gmail.com>
Date:   Wed, 11 Jun 2014 15:21:21 +0200

Fix a bug and add the usage.

Diffstat:
Mpronunciask | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/pronunciask b/pronunciask @@ -7,6 +7,15 @@ MP3BASE="http://it.forvo.com/player-mp3Handler.php?path=" GETTER="wget -t1 --timeout=5 -q" TMP="/tmp/$(basename $0)" +usage() { +echo -n "Usage: $0 [-h] [-l <lang>] <word> ... +-l <lang> Set the language (default: $LANG) +-h Show this helps +" + +exit 1 +} + run() { [ ! -d "$TMP" ] && mkdir "$TMP" rm -f "${TMP}/*" @@ -28,12 +37,15 @@ run() { } main() { - while getopts "l:" opt; do + while getopts "hl:" opt; do case $opt in - l) LANG=$OPTARG; shift $(echo $OPTIND-1|bc);; + h) usage;; + l) LANG=$OPTARG; esac done + shift "$(echo $OPTIND-1|bc)" + run "$@" }