Bug#322054: [Logcheck-devel] Bug#322054: Added GNU --long options support (for scripts)
Jari Aalto
jari.aalto at cante.net
Thu Aug 18 14:28:22 UTC 2005
| On Tue, 09 Aug 2005, Jari Aalto wrote:
|
| > Add GNU --long option alternatived as well. They are more readable
| > in scripts where cryptic "-s" or "-o" can't be remembered after
| > a month.
|
| well the built in bash getopts can't handle long options.
| that's what logcheck uses.
| so i guess that bug should be reassigned to bash as wishlist.
Would it be possible to switch to use getopt(1) which is pretty
standard in Linux. An example in bash follows.
Jari
-------
local retval="/tmp/$0.$FUNCNAME.$$"
getopt \
-n $id \
--long checkout,debug:,Debug:,email:,file:,passphrase:,nomore-space,sign:,release:,Prefix:,sign:,test,verbose,Version,no-strip \
--option cDd:e:f:mp:Pr:s:tvVx -- "$@" \
> $retval
if [ $? != 0 ] ; then
Exit 1 "$id: Cannot read options."
fi
eval set -- $(< $retval)
while true
do
case $1 in
-c|--checkout)
OPTION_VC_PACKAGE="yes" # global-def
shift 1
;;
-d|--debug)
if [[ "$2" != [0-9] ]]; then
Exit 1 "-- [FATAL] Debug is not numeric; got [$2]"
fi
OPTION_DEBUG=$2 # global-def
shift 2
;;
--) shift
break
;;
-*) Exit 1 "$id: Unknown option [$1]. Aborted."
;;
esac
done
More information about the Logcheck-devel
mailing list