kazdy to resi jinak .. ja osobne nepouzivam **getopts ale spis **shiftuju .. tohle je ukazka z meho kodu:
## some functions
usage() {
cat << 'EOF'
usage: irssi-for-solaris-sparc.bin [-h] [-b dir] [-t dir] [-x] [-X] [-V file] [-P opts] [-T term] [-U]
-h : prints out this help message
-b dir : a directory where will be irssi.sh placed, default is /usr/bin
-t dir : temporary directory for unpacking files, default is /var/tmp/irssi-installer
-x : don't delete temporary files
-X : quit before installing so no changes will be made
-V file : where will be stored a pkgadd/pkgrm log, default is /dev/null
-P opts : additional pkgadd opts, default is "-G", refer to pkgadd(1m) manual
: you must enclose opts in "doublequotas"
-T term : a $term will be used rather then xterm-color deployed by this installer
-U : uninstall, if you changed where was a irssi.sh placed, you need to add a "-b dir" option
examples:
irssi-for-solaris-sparc.bin ## just install everything with default settings
irssi-for-solaris-sparc.bin -U -b /foo ## uninstall everything including /foo/irssi.sh
irssi-for-solaris-sparc.bin -t /foo -x -X ## only unpack data archive into /foo and exits
irssi-for-solaris-sparc.bin -b /bin -t /tmp/foo -x -V /tmp/foo/install.log ## install irssi.sh
into /bin, use /tmp/foo for temporary data, won't delete them and save a log as /tmp/foo/install.log
background:
This installer will do generally 3 things:
- installs additional packages GNUglib, GNUirssi and GNUlibiconv compiled with prefix /opt/gnu
- places a xterm-color terminal file which doesn't suck (like Sun's xtermc) in /usr/share/lib/terminfo/x
- creates a /usr/bin/irssi.sh launcher (default path), which you will use for launching irssi
authors:
xxx@opensuse.org - this installer
xxx@synack.fi - packager
EOF
exit 0;
};
checkfail() {
echo "$1";
exit $2;
};
## 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
^^ dal jsem tam pro jistotu i obsah funkce checkfail a --help aby se to lepe chapalo ..
ave, ntz