Casper.Dik at sun.com wrote: > > > > >> cc: don.cragun at sun.com lee.damico at sun.com > >> Subject: Re: [shell-discuss] Is "-#" a valid option for POSIX "getopts" ? > >> -------- > >> > >>> Does anyone know whether the POSIX version of "getopts" allows the > >>> character "#" to be used as option (e.g. > >>> > >> > >> The standard says that option characteers that are not alphanumeric > >> produces unspecified results. > > > >This has never stopped the Sun Studio compilers from using it for years. > > > >$ uname -a > >SunOS fossil 5.8 Generic_117350-56 sun4m sparc SUNW,SPARCstation-20 Solaris > >$ /opt/SUNWspro/bin/cc -V > >cc: Sun C 5.5 Patch 112760-19 2007/08/02 > >usage: cc [ options] files. Use 'cc -flags' for details > > > >Flags that are interesting are : > > > >-# Verbose mode > >-### Show compiler commands built by driver, no compilation > > So it's fine for a Solaris application or any other application which is > supported on a particular platform. > > But it can't be used in portable programs. > (So fine for Sun's C compiler; not a good plan for, say, ksh93)
Umpf... the actual idea was to find a "free option" which could be used to define a new output format for /usr/bin/ls. The idea is to have something like this: -- snip -- $ ls -l -# compound /usr/share/lib/pub/ ( basename=ascii dirname=/usr/share/lib/pub/ mask=-rw-r--r-- numblocks=1 owner=( user=root group=bin ) filesize=2114 date='Feb 20 2008' ) ( basename=eqnchar dirname=/usr/share/lib/pub/ mask=-rw-r--r-- numblocks=1 owner=( user=root group=bin ) filesize=2908 date='Feb 20 2008' ) ( basename=greek dirname=/usr/share/lib/pub/ mask=-rw-r--r-- numblocks=1 owner=( user=root group=bin ) filesize=475 date='Feb 20 2008' ) -- snip -- The idea is to turn the output into a sequence of compound variables which are consumed by the shell's "read -C varname" (or a converter application which turns this into an XML document, list set, set of serialised java variables etc.). This would solve the whole parsing mess in shell scripts and replace it with a reliable (e.g. no problems caused by quoting/whitespaces or special characters), fast (no special parser implemented in a shell script and future-proof (e.g. new stuff can be added as new compound sub-variables and do not interfer with existing applications) solution (this is subject to a paper I am writing currently for the upcoming CommunityOne conference which shows some details, interoperabilty, performace, overhead and other nits). ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;)