BASH alias $1 $2 ... query

dave selby dave6502 at googlemail.com
Sun Apr 19 10:01:45 UTC 2009


2009/4/19 Nils Kassube <kassube at gmx.net>:
> dave selby wrote:
>> I am writing an svn alias that does some stuff before it svn's
>>
>> #!/bin/bash
>>
>> echo -e '\n*** SAFE SVN ***\n'
>>
>> some tidying up  ....
>>
>> svn $1 $2 $3 $4 $5 $6 $7 $8 $9
>>
>> It works but '$1 $2 $3 $4 $5 $6 $7 $8 $9' is clumsy and does not
>> always work - is there a neater way
>
> Sure.
>
> svn $@
>
> However I don't know why your method doesn't always work. There could be
> at least 2 reasons:
>
> a) There may be more than 9 parameters but you only use the first 9.
>
> b) You didn't quote your parameters. If there are spaces in the original
> parameters you would actually call svn with something wrong. Example:
> You originally call your script with
>
> myscript "first parameter" "second parameter"

Thats the problem I have :)

> The script would call svn with 4 parameters instead of 2:
>
> svn "first" "parameter" "second" "parameter"
>
> Therefore it would be better to use
>
> svn "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
>
> But don't use quoting with $@. If you used
>
> svn "$@"
>
> it would be only one parameter like this:
>
> svn "first parameter second parameter"

Many thanks, thats great

dave

>
>
> Nils
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>



-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html




More information about the ubuntu-users mailing list