Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created August 30, 2018 23:58
Show Gist options
  • Save cablehead/1cb0e5270975d94b361e3a1018b8d94d to your computer and use it in GitHub Desktop.
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
$ 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