Bash: A multiword variable breaking curl -



Bash: A multiword variable breaking curl -

i having little problem in bash.

i have rather ugly line

curl -u "$user:$pass" --request post --data '{"title": "'$branch_name'", "body": "'$description'", "head": "'$owner':'$branch_name'", "base": "develop"}' https://api.github.com/repos/$owner/$repo_name/pulls

where of these variables single words $description can more 1 seems breaks line.

is there way create $description not break curl command when has more 1 word in it?

using shell here-doc, safer (y)our brain(s) :

curl \ -x post \ -h "content-type:text/json" \ -d@- \ "https://api.github.com/repos/$owner/$repo_name/pulls" <<eof { "title": "$branch_name", "body" : "$description", "head" : "$owner:$branch_name", "base" : "develop" } eof -x switch same --request -d switch same --data you can replace d@- -d@/dev/stdin if exists. @ -d switch means read file

the simple et proper solution =)

bash

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -