retry_curl "http://example.org/file1.txt"But I have one place where I want to call it like this:
LOCAL_CURLOPTS="--time-cond \"Tue, 11 Aug 2009 18:12:12 -0500\"" retry_curl $LOCAL_CURLOPTS "http://example.org/file1.txtAnd what I get on the console is:
curl: option -0500: is unknown curl: try 'curl --help' or 'curl --manual' for more informationSo somewhere bash is breaking apart my LOCAL_CURLOPTS as words, and then using that in the command substitution. What I can't figure out is how to get it to stop.
CURLOUT=$(curl $CURLOPTS "$@")And then splitting my call into:
if [ -n "$TIME_COND" ]; then retry_curl --time-cond "$TIME_COND" "http://example.org/file1.txt" else retry_curl "http://example.org/file.txt" fiDoes that look right to the bash experts out there?
stephen@jellybelly:~$ PROMPT_COMMAND=
stephen@jellybelly:~$ set -x
stephen@jellybelly:~$ cruel=kind
+ cruel=kind
stephen@jellybelly:~$ cry="goodbye \"$cruel world\""
+ cry='goodbye "kind world"'
stephen@jellybelly:~$ echo $cry
+ echo goodbye '"kind' 'world"'
goodbye "kind world"
stephen@jellybelly:~$ echo "$cry"
+ echo 'goodbye "kind world"'
goodbye "kind world"
DEFAULTS="big list of default options"
command $DEFAULTS more options
augmented_command () { command big list of default options "$@" ; }
augmented_command more options
local_curl () { retry_curl --time-cond "Tue, 11 Aug 2009 18:12:12 -0500" "$@" ; }
local_curl http://example.org/file1.txt
LOCAL_CURLOPTS=(--time-cond "Tue, 11 Aug 2009 18:12:12 -0500")
retry_curl "${LOCAL_CURLOPTS[@]}" http://example.org/file1.txt
LOCAL_CURLOPTS=(--time-cond "Tue, 11 Aug 2009 18:12:12 -0500")
retry_curl "${LOCAL_CURLOPTS[@]}" http://example.org/file1.txt
If I remove the double quotes from around ${LOCAL_CURLOPTS[@]}, then bash passes my function 8 parameters, instead of 3?
stephen@chironex:~$ PROMPT_COMMAND=
stephen@chironex:~$ set -x
stephen@chironex:~$ LOCAL_CURLOPTS=(--time-cond "Tue, 11 Aug 2009 18:12:12 -0500")
+ LOCAL_CURLOPTS=(--time-cond "Tue, 11 Aug 2009 18:12:12 -0500")
stephen@chironex:~$ : "${LOCAL_CURLOPTS[@]}"
+ : --time-cond 'Tue, 11 Aug 2009 18:12:12 -0500'
stephen@chironex:~$ : ${LOCAL_CURLOPTS[@]}
+ : --time-cond Tue, 11 Aug 2009 18:12:12 -0500
CURLOUT="$(curl "${CURLOPTS[@]}" "$@")"
CURLOUT=$(curl "${CURLOPTS[@]}" "$@")
You are not logged in, either login or create an account to post comments
posted by Obscure Reference at 4:38 PM on August 11