[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: last argument expansion has different output using the sh interprete
Re: last argument expansion has different output using the sh interpreter
Fri, 27 May 2011 17:11:04 -0700
On Fri, 2011-05-27 at 14:57 -0600, Bob Proulx wrote:
> Jacoby Hickerson wrote:
> > Although, I am curious, is this is a matter of sh being continually
> > updated to exclude all bash extensions or perhaps previously bash
> > didn't interpret #!/bin/sh to be the POSIX compliant interpreter?
> When bash is invoked as sh then bash complies with the POSIX sh. That
> is both required and desired.
> On some GNU/Linux systems /bin/sh is a symlink to /bin/bash and bash
> will support running as a POSIX sh. But this isn't universal. On
> other systems /bin/sh is an actual native POSIX sh, on others it is a
> symlink to /bin/ksh or /bin/zsh or /bin/dash or others. But in all
> cases /bin/sh is supposed to be a POSIX sh and conform to the
> standard. Bash tries to be compliant but some differences will creep
> in regardless. Doing so may cause problems for people who unknowingly
> use features on one system that are not available on other systems.
> Generally the wisdom of years is not to be generous in what you accept
> but to be strict in what you accept. It makes portability easier.
> Having found that the bash specific feature isn't available in /bin/sh
> this is a good thing for you since now your script will either need to
> specify that it needs bash explicitly or you could use portable only
> constructs and continue to use /bin/sh. Personally I use bash for my
> command line but /bin/sh and portable constructs for shell scripts.
Yes in this environment it is a link. It certainly makes sense to write
it in a POSIX compliant way in order to be portable, but some extended
features of bash make life easier. Since this was an upgrade from a
previous distro Fedora 14 -> Fedora 15, I didn't think portability with
a shell script would be an issue, but now it is much more clear after I
have been bitten :). Your response is very excellent information and
thanks to you all for the wealth of data.
Re: last argument expansion has different output using the sh interpreter, Chet Ramey, 2011/05/28