I have a following bash script:
1 #!/bin/bash
2 query='query= SELECT * WHERE { ?s ?p ?o } LIMIT 5'
3 cmd="curl $1 -s -d \"$query\""
4 echo "$cmd"
5 # curl $1 -s -d "$query"
6 # $cmd
5th and 6th lines must do the same. When i uncomment the 5th line, everything works fine. But with the 6th line nothing doesn’t work.
So i’m wondering whats the difference?
Thanks.
Line 5 passes
$queryas a single argument. Line 6 passes each word of$queryas a separate argument, with"at the beginning of the first and"at the end of the last. Put your arguments in an array instead.