0

How can I give a parameter to a subshell that has to be written in quotes?

I have a bash function that does something with data, lets call it check_data:

check_data() {
    echo "I check data. \"$1\" looks good."
}

When I call it, I have to quote the parameter, if it contains spaces:

check_data "Adam Brutus Caesar"

But now I want to check the results of a curl request:

check_data $(curl --silent 'http://my.web.site.cool/myPath?arg1=Hey&arg2=Ho&arg3=$SESSIONID&arg4=Hi')

That of course only works if the result is a single word, otherwise only the first word would be checked. But when I quote the entire thing, ...

check_data "$(curl --silent 'http://my.web.site.cool/myPath?arg1=Hey&arg2=Ho&arg3=$SESSIONID&arg4=Hi')"

...arg3 is not given the content of $SESSIONID but the String $SESSIONID instead.

What am I missing here?

Bowi
  • 101

0 Answers0