api-helper: Don't use echo to redirect command output

This commit is contained in:
Samantaz Fox 2023-02-20 22:44:33 +01:00
parent 86f9ce3742
commit 0fce8c7b16
No known key found for this signature in database
GPG key ID: F42821059186176E

View file

@ -504,17 +504,18 @@ hdr_ua="User-Agent: ${user_agent}"
# Run! # Run!
result=$( temp_dl=_curl_$(date '+%s')
curl --compressed -H "$hdr_ct" -H "$hdr_ua" --data "$data" "$url" | \
sed -E '
/^\s+"(clickT|t)rackingParams.+,$/d
s/,?\n\s+"(clickT|t)rackingParams.+$//
'
)
# Default to STDOUT if no output file was given curl --compressed -H "$hdr_ct" -H "$hdr_ua" --data "$data" "$url" | \
sed -E '
/^\s+"(clickT|t)rackingParams.+,$/d
s/,?\n\s+"(clickT|t)rackingParams.+$//
' > "$temp_dl"
# Print to STDOUT if no output file was given
if [ -z "$output" ]; then if [ -z "$output" ]; then
echo "$result" cat "$temp_dl"
rm "$temp_dl"
else else
echo "$result" > "$output" mv -- "$temp_dl" "$output"
fi fi