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: Jacoby Hickerson
Subject: Re: last argument expansion has different output using the sh interpreter
Date: Fri, 27 May 2011 13:35:50 -0700

On Fri, May 27, 2011 at 1:20 PM, DJ Mills <danielmills1@gmail.com> wrote:

>
>
> On Fri, May 27, 2011 at 3:45 PM, Greg Wooledge <wooledg@eeg.ccf.org>wrote:
>
>> On Fri, May 27, 2011 at 12:35:12PM -0700, Jacoby Hickerson wrote:
>> >         When executing a test script using the #!/bin/sh interpreter
>> line
>> > the shell expansion for the last argument ${!#} is blank,
>>
>> Good.  And now you know why you use a proper #!/bin/bash shebang when
>> you use bash extensions in your script.
>>
>> If you are using #!/bin/sh then you should use only POSIX sh features.
>>
>>
> Indeed, indirection is a bash feature.  I wouldn't expect it to work in
> POSIX sh.
>
> The only way I can think of to get the last argument in sh is to loop
> through them,
> something like:
> for arg; do last="$arg"; done; echo "$last"
>

Ah I see that inderection is a bash specific feature, in general I should
update all my scripts.  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?


reply via email to

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