Why is the output of test foo bar only foo instead of foo bar?
$ cat test
function f
{
local args=$1
echo $args
}
f "$@"
$ bash test foo bar
foo
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To pass the command-line parameters as a single argument to your function you can join them together using
"$*"(instead of$@):The first character of variable
IFSis used as the “glue” between each parameter, the default is a single space.