RHAT bug? /etc/init.d/functions:daemon()

Steven W. Orr steveo at syslang.net
Wed Feb 1 12:11:02 EST 2006


On Wednesday, Feb 1st 2006 at 11:16 -0500, quoth Michael ODonnell:

=>
=>
=>> I thought providing getopt *as a shell function* was a GNU
=>> extension.  Hmmm...  well, 60 seconds of Google work didn't find
=>> a definitive answer.  :)
=>
=>You went all the way to Oz when the answer was right in
=>your own back yard:

Don't confuse getopt for getopts. :-)

=>
=> # echo $BASH_VERSION 
=> 2.05b.0(1)-release
=> # type getopts
=> getopts is a shell builtin
=> # help getopts
=> getopts: getopts optstring name [arg]
=>     Getopts is used by shell procedures to parse positional parameters.
=>
=>     OPTSTRING contains the option letters to be recognized; if a letter
=>     is followed by a colon, the option is expected to have an argument,
=>     which should be separated from it by white space.
=>
=>     Each time it is invoked, getopts will place the next option in the
=>     shell variable $name, initializing name if it does not exist, and
=>     the index of the next argument to be processed into the shell
=>     variable OPTIND.  OPTIND is initialized to 1 each time the shell or
=>     a shell script is invoked.  When an option requires an argument,
=>     getopts places that argument into the shell variable OPTARG.
=>
=>     getopts reports errors in one of two ways.  If the first character
=>     of OPTSTRING is a colon, getopts uses silent error reporting.  In
=>     this mode, no error messages are printed.  If an invalid option is
=>     seen, getopts places the option character found into OPTARG.  If a
=>     required argument is not found, getopts places a ':' into NAME and
=>     sets OPTARG to the option character found.  If getopts is not in
=>     silent mode, and an invalid option is seen, getopts places '?' into
=>     NAME and unsets OPTARG.  If a required option is not found, a '?'
=>     is placed in NAME, OPTARG is unset, and a diagnostic message is
=>     printed.
=>
=>     If the shell variable OPTERR has the value 0, getopts disables the
=>     printing of error messages, even if the first character of
=>     OPTSTRING is not a colon.  OPTERR has the value 1 by default.
=>
=>     Getopts normally parses the positional parameters ($0 - $9), but if
=>     more arguments are given, they are parsed instead.
=> 
=>_______________________________________________
=>gnhlug-discuss mailing list
=>gnhlug-discuss at mail.gnhlug.org
=>http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
=>

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the gnhlug-discuss mailing list