Propagate all arguments in a bash shell script
Use "$@"
instead of plain $@
if you actually wish your parameters to be passed the same.
Observe:
$ cat no_quotes.sh#!/bin/bashecho_args.sh $@$ cat quotes.sh#!/bin/bashecho_args.sh "$@"$ cat echo_args.sh#!/bin/bashecho Received: $1echo Received: $2echo Received: $3echo Received: $4$ ./no_quotes.sh first secondReceived: firstReceived: secondReceived:Received:$ ./no_quotes.sh "one quoted arg"Received: oneReceived: quotedReceived: argReceived:$ ./quotes.sh first secondReceived: firstReceived: secondReceived:Received:$ ./quotes.sh "one quoted arg"Received: one quoted argReceived:Received:Received:
Use "$@"
(works for all POSIX compatibles).
[...] , bash features the "$@" variable, which expands to all command-line parameters separated by spaces.
From Bash by example.