BASH alias $1 $2 ... query
Nils Kassube
kassube at gmx.net
Sun Apr 19 09:49:48 UTC 2009
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"
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"
Nils
More information about the ubuntu-users
mailing list