bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: last argument expansion has different output using the sh interprete


From: Chet Ramey
Subject: Re: last argument expansion has different output using the sh interpreter
Date: Sat, 28 May 2011 18:17:32 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]