On Tue, 4 Feb 2003 19:22:05 -0800 "Sean 'Shaleh' Perry" <[EMAIL PROTECTED]> wrote:
> On Tuesday 04 February 2003 13:26, Sam Halliday wrote:
> > > bsetbg should be a POSIX shell compliant script
> > > and run fine under /bin/sh. If it doesn't, post
> > > the error so we can debug it.
> >
> > sorry, didnt realise you were going for POSIX there...
> > how silly of me and my little bashy world :D
> >
>
> yes, POSIX is preferred.
/bin/sh on Solaris is not a POSIX shell. Sucks, I agree but there it
is.
> > the error is:
> > "./bsetbg: bad substitution"
> >
> > no error line or anything :-/
> >
> > by inserting debugging output in the script i narrowed
> > the problem line down to
> >
> > me=${0##*/}
> >
> > (line 64)
> >
>
> how odd. All of the shells that act like bourne (posix) shells I have
> access to accept this notation.
When you're old like me, you know that the Bourne shell (as written by
Steve Bourne, presumably then at Bell Labs) predates the posix
standardization efforts in the shell by something approaching 20 years.
The /bin/sh that Sun has been shipping with Solaris 2 since 1992 has
always been the Bourne Shell. Incidentally, last I heard, Steve Bourne
holds the title of "Sun Fellow".
The above quoted syntax was born in the Korn Shell (circa 1988 by David
Korn, also at the Labs). It is this shell that was put forward (with a
few changes) that was standardized in IEEE 1003.2 (POSIX) in 1992 (also
IS0/IEC 9945-2:1993) and later picked up by X/Open (now The Open Group)
in the XPG4 (XPG == X/Open Portability Guide) specification. (Solaris
offers this shell in /usr/xpg4/bin/sh).
None of this helps the poor bastard that's trying to decide WTF to put
after the !# at the top of a script (worth pointing out that old UNIXes
don't even support !#, but that's another problem, see the gymnastics
that some early Larry Wall (yes, the Perl guy) scripts did.
Script authors/maintainers have two choices.
1. Limit their use of the shell language to the subset of the shell
language that is relatively guaranteed to be supported on all platforms.
2. Answer these kinds of questions forever. (Complete with the
accompanying rants about inflexible and evil OS vendors and where
forever is defined as until Linux takes over the world and there is only
one true platform ;-) ]
Lastly:
me=${0##*/}
can be rewritten portably:
me=`basename $0`
Yes, there's an extra fork/exec but since one tends to limit their
setting of a background to once a session, so who gives a rats ass.
Hopefully, all that arcana was worth the electrons...
-g
msg00764/pgp00000.pgp
Description: PGP signature
