[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: last argument expansion has different output using the sh interprete
From: |
DJ Mills |
Subject: |
Re: last argument expansion has different output using the sh interpreter |
Date: |
Fri, 27 May 2011 16:20:20 -0400 |
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"
Re: last argument expansion has different output using the sh interpreter, Chet Ramey, 2011/05/28