I have a script that runs curl. I want to be able to optionally add a -H parameter, if a string isn\'t empty. What\'s complex is the levels of qu
curl
-H
The key to making this work is to use an array.
caption="Test Caption" if [[ $caption ]]; then CAPT=(-H "X-Caption: $caption") fi curl -A "$UA" -H "Content-MD5: $MD5" -H "X-SessionID: $SID" -H "X-Version: 1" "${CAPT[@]}" "http://upload.example.com/$FN"