[olug] bash script help

David Walker linux_user at grax.com
Thu Oct 3 19:23:33 UTC 2002


Change the last line from 
echo "$@" 
to
$@
and have this script do the calling of the next script instead of returning 
the command to use.

On Thursday 03 October 2002 01:58 pm, (Via wrote:
> I've got a bit of a complex bash script problem.  I need to change the
> value of the last positional argument passed to the script, in order to
> pass the arguments on to another script/program.  Here's my first (naive)
> attempt:
>
> # script "test"
> let idx=$#-1
> set "${@:0:$idx} new-value"
> echo "$@"
>
> The problem with this is in quoting (which often makes my head hurt).
> Here's a sample usage that works:
>
> $test foo bar widget
> foo bar new-value
>
> However, this usage doesn't work correctly:
>
> $test "foo bar" widget
> foo bar new-value
>
> What I need would be this output instead:
>
> "foo bar" new-value
>
> Anyone know of a way to achieve this?  I suppose I could take a brute force
> approach and loop through every argument appending them to a variable with
> quotes around it... but the extra quotes this would produce bug me a bit,
> and this seems like it would be an awfully slow way to do this.
>
> Bill Kempf
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug




More information about the OLUG mailing list