Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bash helper for curl plus jq
#!/bin/bash
curl_args=()
for arg
do
case "$arg" in
-- ) shift ; break ;;
* ) curl_args=("${curl_args[@]}" "$arg") ; shift ;;
esac
done
jq_args=("${@-.}")
curl -s -D - "${curl_args[@]}" | tr -d '\r' | {
while read line
do
case "$line" in
'' ) echo ; break ;;
* ) echo "$line" ;;
esac
done
exec jq "${jq_args[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment