export in posix mode

2013-02-27 Thread James Mason
I certainly could be doing something wrong, but it looks to me like bash 
- when in Posix mode - does not suppress the "-n" option for export.   
The version of bash that I'm looking at is 3.2.25.


-jrm




Re: export in posix mode

2013-02-27 Thread James Mason

On 02/27/2013 04:00 PM, Bob Proulx wrote:

Eric Blake wrote:

James Mason wrote:

I certainly could be doing something wrong, but it looks to me like bash
- when in Posix mode - does not suppress the "-n" option for export.
The version of bash that I'm looking at is 3.2.25.

So what?  Putting bash in posix mode does not require bash to instantly
prohibit extensions.  POSIX intentionally allows for implementations to
provide extensions, and 'export -n' is one of bash's extensions.
There's no bug here, since leaving the extension always enabled does not
conflict with subset of behavior required by POSIX.

If you are looking to try to detect non-portable constructs then you
will probably need to test against various shells including ash.  (If
on Debian then use dash.)

   https://en.wikipedia.org/wiki/Almquist_shell

The posh shell was constructed specifically to be as strictly
conforming to posix as possible.  (Making it somewhat less than useful
in Real Life but it may be what you are looking for.)  It is Debian
specific in origin but should work on other systems.

   http://packages.debian.org/sid/posh
   http://anonscm.debian.org/gitweb/?p=users/clint/posh.git;a=summary

Bob


We considered setting up another shell as the implementation of 
"/bin/sh", but that's hazardous in the context of vast amounts of 
boot-time initialization scripting that hasn't been vetted as to 
avoidance of bash-isms.


Changing product script code - just so you can look for these sorts of 
things - isn't practical (or safe) either.


So I guess if you take the view that bash POSIX mode exists only to make 
bash accept POSIX scripts, and not to preclude/warn about behavior that 
isn't going to be acceptable elsewhere, then you're right - it's not a 
bug.   If you care about helping people to be able to write scripts that 
work various places and don't exceed the POSIX specification, you're 
unhelpfully wrong (and you might contemplate why "bashisms" gives > 50K 
google hits).


-jrm