Skip to content

Instantly share code, notes, and snippets.

@binkley
Created December 21, 2015 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binkley/5d53a0071c4ef207237e to your computer and use it in GitHub Desktop.
Save binkley/5d53a0071c4ef207237e to your computer and use it in GitHub Desktop.
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