Created
August 30, 2018 23:58
-
-
Save cablehead/1cb0e5270975d94b361e3a1018b8d94d to your computer and use it in GitHub Desktop.
set a shell's environment to the key / value pairs in a JSON mapping
This file contains hidden or 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
$ jo foo=bar | \ | |
jq -r 'to_entries | map("\(.key)=\(.value | @sh)") | join(" ")'| \ | |
while read -r line ; do | |
eval "$line" | |
echo $foo | |
done | |
bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment