oddities in /sbin/service

James Wilkinson fedora at aprilcottage.co.uk
Mon Nov 20 13:47:09 UTC 2006


Robert P. J. Day wrote:
>   first, as an exercise for the reader, what is so amusing about
> *this* snippet of script:
> 
> 
>     case "${1}" in
>       --help | -h | --h* )

Jeff Vian wrote:

> As standard syntax for the case statement I don't see anything funny.
> Please enlighten us.

Well, one could argue that the --help was superfluous, given that it
would have been caught by the --h*, but it does help document what the
option *means*.

The "${1}" does make a good example of careful shell programming, how to
handle quotes and spaces, and the fact that if a user quotes a space so
that a longer string will be passed to the script as its first argument,
then the quotes the user provided will be stripped off, and the shell
needs to provide its own quotes if it wants to be sure that the first
argument is, in fact, one argument...

James.

-- 
E-mail:     james@ | "Minis on the other hand are just the wrong size. Too
aprilcottage.co.uk | small to work on directly and too large to put upside
                   | down on the workbench."
                   |     -- stevo at madcelt.org




More information about the fedora-list mailing list