0

I have an sittuation when I try to handle variables in bash scripts.

dev.sh

#!/bin/bash
params="--context_param token_env=a c"
echo  ${params}
echo "$@"
sh job.sh $params "$@"

and destination script(originally provided by talend open studio, but changed for testing purpose)

job.sh

#!/bin/sh
for a in "$@"; do
   echo $a;
done

And then when I invoke the script like that:

./dev.sh --context_param token_param="a b"

I got:

--context_param token_env=a c
--context_param token_param=a b
-e
Using "$@":
--context_param
token_env=a
c
--context_param
token_param=a b

But I expect

--context_param token_env=a c
--context_param token_param=a b
-e
Using "$@":
--context_param
token_env=a c
--context_param
token_param=a b

How can I pass this variable to handle spaces, or where is the source of this difference?

0 Answers0