Quote:
Originally Posted by bigearsbilly
bash --posix doesn't work
e.g
export X=y
should error in a sh script, it don't.
|
I don't know of any current bourne or korn based shell that doesn't allow export X=y. POSIX mode for bash deals more so with making bash mimic the standards behavior for things like output formats and file searches; then actually turning stuff off. For a long time, I wondered why everyone wrote 'FOO=bar; export FOO' when 'export FOO=bar' works everywhere. Then I tried shells/v7sh, and was enlightened.
Really if you want a truly portable sh script, you have to find a suitable LCD. Most of the fun stuff didn't exist until like System III or 4.3BSD or so, and most shells that I've seen around seems to be as good as SysV family or later. I think solaris uses a SVR4 based sh. Most of the really fun stuff was added later or pioneered by csh.
For super portability, you can't use named() { functions }, $(( arithmetic substitutions )), command aliases, shell history, directory stacks, no $( command substitutions ) instead of `back {quote,ticks,tocks,whatevers}`, more restricted here-doc, redirection, and ${ variable expansion } syntax and shell globing would basically limited to the * and ? metacharacters for most purposes. Not to mention that 'array' like data structures in portable sh scripting amounts to constructs like `for word in words ...; do something -with $word; done`