Re: Window manager policy question
On Wed, Jul 29, 1998 at 01:32:31PM -0400, Shaleh wrote:
> Dumb question -- how do you get sh or what not to take long options (the
> --add type options you mentioned). Or even perl. I have never written
> an app that used them. Always used -foo or foo.
In bash there's getopts (I don't know if that does long options or not). In
perl you can use Getopt::Long (or take a look at update-inetd). Anyway,
there's nothing special about long options in the shell, they are parsed in
the same way as other arguments...
In sh:
while [ $# -ne 0 ] ; do
case $1 in
--option-with-argument|-a)
# do something with $2
shift
;;
--option-with-optional-argument|-b)
if [ "$2" ] ; then
# do something with $2
shift
else
# do something else with a default value
fi
;;
--option-without-argument|-c)
# do something
;;
esac
shift
done
if you want to get funky about it, long options should take the form
--option=value..
Marcelo
--
To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: