I've defined a short helper function in a bash script. For legibility, I'd like to replace the boilerplate headers with a variable declared outside the function.
I've tried quoting the declaration many different ways, but nothing's working.
I want to replace this
put() {
local response=$(curl -H 'Content-Type: application/json' -H 'Accept: application/vnd.urbanairship+json; version=3;' ...)
echo $response
}
with something like this
headers=???
put() {
local response=$(curl $headers ...)
echo $response
}
i.e.
$headers
should expand to -H 'Content-Type: application/json' -H 'Accept: application/vnd.urbanairship+json; version=3;'
$headers
needs to expand to separate words to get passed properly as arguments, so I've even tried using an array.
Note: I've pretty much given up. It's not worth fighting with for such a simple use. At this point the question is for edification.
Asked by Hod
(101 rep)
Feb 14, 2017, 01:56 AM
Last activity: May 31, 2023, 05:33 PM
Last activity: May 31, 2023, 05:33 PM