On 5/27/11 3:35 PM, Jacoby Hickerson wrote:

> Bash Version: 4.2
> Patch Level: 10
> Release Status: release
> 
> Description:
>         When executing a test script using the #!/bin/sh interpreter line
> the shell expansion for the last argument ${!#} is blank,
>         however when using #!/bin/bash the behavior is as expected.  In this
> setup /bin/sh is a link to /bin/bash.

The ${!#} and ${!?} expansions do not perform variable indirection when
bash is running in posix mode (as it is when invoked as `sh').  Those
particular expansions have other meanings specified in the Posix standard,
and running in posix mode overrides the normal bash behavior with the
Posix behavior.

${!?} means to print a standard error message and exit if the $! is unset,
as when there haven't been any background processes.

#{!#} means to remove the empty string from the beginning of $!

It is an oversight that these are not documented in the `Posix Mode'
section of the texinfo manual.  I'll add that for the next version.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to