0

I am looking a way to use variable inside "file=@/my/file/path/from/variable/tshootinginfo.txt" in a bash shell on Debian 9.3.

My CURL request:

curl -s -k -D- -u ${user}:${password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=@/my/file/path/from/variable/tshootinginfo.txt" ${jira_subtask}/attachments

I have tried multiple different escapes known to me in a bash, but no much progress. The escape tried:

location_var="/my/file/path/from/variable/tshootinginfo.txt"

-F "file=\"@$location_var\""
-F "file=@\"$location_var\""
-F "file=@\'$location_var\'"
-F "file=@\${location_var}"
datacruncher
  • 155
  • 1
  • 1
  • 13

1 Answers1

1

The argument after -F file=@... is simply a string.

curl -s -k -D- -u "${user}:${password}" \
    -X POST -H "X-Atlassian-Token: nocheck" \
    -F "file=@$my_location_var" \
    "${jira_subtask}/attachments"

You can put braces around the variable name if you like, but it is not necessary in any of these cases. Take care to quote your variables properly, though.

tripleee
  • 175,061
  • 34
  • 275
  • 318