Created
June 5, 2019 05:52
-
-
Save ORESoftware/bc74a07153193d7926ceda12cc4d0c6f to your computer and use it in GitHub Desktop.
JQ does not make it easy to sanitize strings for JSON inclusion
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 | |
hist='sed '0,1d' "$HOME/my_bash_history" | wc -l' ### <<< we have some double quotes to escape | |
data="$( jq -nc --arg str "$hist" '{"attr": $str}' )" | |
echo "data: $data" | |
hist="$(echo "$data" | jq -r '.attr')" | |
echo "hist: $hist" # damnit it's back to where it was before | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment