Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bash script that is a simple wrapper around another process:

$ cat ~/bin/s3cmd
trickle -u 80 ~/bin/s3cmd.py $*

This works great when the parameters don't contain spaces. However, it seems to fail whenever the parameters passed to the outer s3cmd script contain spaces, even if those are escaped on the command line.

How do I whitespace-proof this, such that each single parameter is passed on properly to s3cmd.py?

share|improve this question
up vote 6 down vote accepted

Use "$@".

trickle -u 80 ~/bin/s3cmd.py "$@"

There is no functional difference between $* and $@ is when undergoing implicit word splitting (almost always when unquoted). When quoted, however, $* is a single string separated by the first character of IFS, and "$@" is a real array (what you want).

$ set foo bar baz
$ IFS=c
$ printf '%s\n' "$@"
$ printf '%s\n' "$*"
share|improve this answer
Note that there can be differences between $* unquoted and $@ unquoted under some circumstances with some shells. See for instance set a b; IFS=; a=$@; b=$*; echo "$a,$b" in bash or AT&T ksh. Also note that in the Bourne shell (but who cares about the Bourne shell nowadays) SPC is used to separate items in "$*", not the first character of $IFS. – Stéphane Chazelas Nov 13 '12 at 21:09
@StephaneChazelas - Perhaps I should have said "when undergoing implicit word splitting" rather than "when unquoted". – Chris Down Nov 13 '12 at 21:10

You'll want to use $@ instead of $* and quote it:

trickle -u 80 ~/bin/s3cmd.py "$@"

See also the Special Parameters section in the bash manpage.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.