Created
February 5, 2022 01:13
-
-
Save mtthlm/b87e4c0abd8a200b116bf1f4f446ba06 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -o errexit -o nounset | |
IFS=$'\n' read -r -d '' < <( | |
while [[ $# -gt 0 ]] | |
do | |
if [[ "$1" =~ ^([a-zA-Z0-9_]+)=(.+)$ ]] | |
then printf -- 'declare -- %s=\(%s|tostring);' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" | |
fi | |
shift | |
done | |
) || true | |
jq --raw-output "@sh \"${REPLY}\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
This little utility makes it easy to parse out JSON values into shell variables.