normalne nepisu nic v /bin/sh a /bin/bash (pouzivam opravdove skriptovaci jazyky), ale vcera jsem po dlooouhe dobe musel a prisel jsem mimo jine na genialni rozparsovani argumentu skriptu .. jak je nize videt tak je tam pouzito jak single parametr [-x] tak napr i parametr co ocekava argument [-b foo]
mam z nej radost a rad bych se s nim pochlubil:
## assigning variables, some of them could be changed by passed cli parameters
bin_path=/usr/bin;
tmp_path=/var/tmp/$0.installer
tmp_del=yes;
pretend=no;
verbose_logfile=/dev/null;
pkgadd_opts="-G";
term="xterm-color";
uninstall=no;
## parsing cli parameters and changing predefined variables
until test -z "$1"; do
case "$1" in
-h | --help ) usage;;
-b ) bin_path="$2"; shift;
test -w $bin_path || checkfail "$bin_path doesn't exist or you have no +w permissions there" 1;;
-t ) tmp_path=$2; shift;;
-x ) tmp_del=no;;
-X ) pretend=yes;;
-V ) verbose_logfile="$2"; shift;
test -f $verbose_logfile && checkfail "$verbose_logfile already exists, choose another one, quitting .." 1;;
-P ) pkgadd_opts="$2"; shift;;
-T ) term="$2"; shift;;
-U ) uninstall=yes;;
* ) checkfail "bad parameter: \"$1\", try -h for help" 1;;
esac
shift;
done