Created
December 21, 2015 13:41
-
-
Save binkley/5d53a0071c4ef207237e to your computer and use it in GitHub Desktop.
Bash helper for curl plus jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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