IPB
>  Man Pages > Unix > Solaris 10 11/06 > Section 1 > getoptcvt man page

getoptcvt man page

Section 1 - Solaris 10 11/06 Man Pages

Other operating system man pages available here


Advanced Search

Hopefully, this page is exactly what you are looking for, but if not, you can always find further assistance on Unix/Linux Forum!





User Commands                                        getoptcvt(1)



NAME
     getoptcvt - convert to getopts to parse command options

SYNOPSIS
     /usr/lib/getoptcvt [-b] filename

     /usr/lib/getoptcvt

DESCRIPTION
     /usr/lib/getoptcvt reads the shell script in filename,  con-
     verts  it  to  use getopts instead of getopt, and writes the
     results on the standard output.

     getopts is a built-in Bourne shell  command  used  to  parse
     positional  parameters  and  to check for valid options. See
     sh(1). It supports all applicable rules of the command  syn-
     tax  standard (see Rules 3-10, intro(1)).  It should be used
     in place of the  getopt  command.  (See  the  NOTES  section
     below.)  The syntax for the shell's built-in getopts command
     is:

     getopts optstring name [ argument...]

     optstring must contain the option letters the command  using
     getopts  will  recognize; if a letter is followed by a colon
     (:), the option is expected to have an argument, or group of
     arguments, which must be separated from it by white space.

     Each time it is invoked, getopts places the next  option  in
     the  shell  variable name and the index of the next argument
     to be processed in the shell variable OPTIND.  Whenever  the
     shell or a shell script is invoked, OPTIND is initialized to
     1.

     When an option requires an option-argument,  getopts  places
     it in the shell variable OPTARG.

     If an illegal option is encountered, ?  will  be  placed  in
     name.

     When the end of options is encountered, getopts exits with a
     non-zero  exit status. The special option  -- may be used to
     delimit the end of the options.

     By default, getopts parses the  positional  parameters.   If
     extra  arguments  (argument  ...)   are given on the getopts
     command line, getopts parses them instead.

     So that all new commands will adhere to the  command  syntax
     standard  described  in intro(1), they should use getopts or
     getopt to parse positional parameters and check for  options
     that  are  valid  for  that  command  (see the NOTES section



SunOS 5.10           Last change: 7 Jan 2000                    1






User Commands                                        getoptcvt(1)



     below).

OPTIONS
     The following option is supported:

     -b       Makes the  converted  script  portable  to  earlier
              releases  of  the  UNIX  system. /usr/lib/getoptcvt
              modifies the shell script in filename so that  when
              the  resulting  shell script is executed, it deter-
              mines at run time  whether  to  invoke  getopts  or
              getopt.



EXAMPLES
     Example 1: Processing the arguments for a command

     The following fragment of a  shell  program  shows  how  one
     might  process the arguments for a command that can take the
     options -a or -b, as well as the option -o,  which  requires
     an option-argument:

     while getopts abo: c
     do
           case $c in
           a | b)     FLAG=$c;;
           o)         OARG=$OPTARG;;
           \?)        echo $USAGE
                      exit 2;;
           esac
     done
     shift `expr $OPTIND - 1`


     Example 2: Equivalent code expressions

     This code accepts any of the following as equivalent:

     cmd -a -b -o "xxx z yy" filename
     cmd -a -b -o "xxx z yy" -filename
     cmd -ab -o xxx,z,yy filename
     cmd -ab -o "xxx z yy" filename
     cmd -o xxx,z,yy b a filename

ENVIRONMENT VARIABLES
     See environ(5) for descriptions of the following environment
     variables  that  affect  the execution of getopts: LC_CTYPE,
     LC_MESSAGES, and NLSPATH.

     OPTIND          This variable is used by  getoptcvt  as  the
                     index of the next argument to be processed.




SunOS 5.10           Last change: 7 Jan 2000                    2






User Commands                                        getoptcvt(1)



     OPTARG          This variable is used by getoptcvt to  store
                     the  argument  if  an  option is using argu-
                     ments.



EXIT STATUS
     The following exit values are returned:

     0        An option, specified or unspecified  by  optstring,
              was found.



     >0       The end of options  was  encountered  or  an  error
              occurred.



ATTRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:

     ____________________________________________________________
    |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
    |_____________________________|_____________________________|
    | Availability                | SUNWcsu                     |
    |_____________________________|_____________________________|
    | CSI                         | enabled                     |
    |_____________________________|_____________________________|


SEE ALSO
     intro(1), getopts(1), sh(1), shell_builtins(1),  getopt(3C),
     attributes(5)

DIAGNOSTICS
     getopts prints an error message on the standard  error  when
     it encounters an option letter not included in optstring.

NOTES
     Although the following command syntax  rule  (see  intro(1))
     relaxations  are permitted under the current implementation,
     they should not be used because they may not be supported in
     future  releases  of  the system. As in the EXAMPLES section
     above, -a and -b are options, and the option -o requires  an
     option-argument.   The  following  example  violates Rule 5:
     options with option-arguments must not be grouped with other
     options:






SunOS 5.10           Last change: 7 Jan 2000                    3






User Commands                                        getoptcvt(1)



     example% cmd -aboxxx filename


     The following example violates Rule 6: there must  be  white
     space after an option that takes an option-argument:


     example% cmd -ab oxxx filename


     Changing the value of the shell variable OPTIND  or  parsing
     different sets of arguments may lead to unexpected results.











































SunOS 5.10           Last change: 7 Jan 2000                    4





Man(1) output converted with man2html and wrapped by fishsponge

This page was generated on Wed Sep 12 11:24:45 GMT 2007

Your favourite pages:

No pages logged yet.
Trying to save cookie...

Top 10 most popular pages:

sqlite3 man page (5084 hits)
(openSUSE 10.2)

adv_cap_autoneg man page (4749 hits)
(Solaris 10 11_06)

CPAN man page (4469 hits)
(Suse Linux 10.1)

svn man page (4249 hits)
(FreeBSD 6.2)

ssh man page (4249 hits)
(Suse Linux 10.1)

ssh-socks5-proxy-connect man page (2207 hits)
(Solaris 10 11_06)

startproc man page (2201 hits)
(Suse Linux 10.1)

netcat man page (2159 hits)
(Suse Linux 10.1)

pprosetup man page (2017 hits)
(Solaris 10 11_06)

signal man page (2009 hits)
(Suse Linux 10.1)

Useful Links

Go Back

Visitor Statistics


Valid XHTML 1.0 Transitional     Valid CSS!

Partners: Cambridge Plus :: Pyrenees Ski Resorts :: Touch Sensor Chip :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum