File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1377,6 +1377,21 @@ Iversonian [[https://www.jsoftware.com/papers/tot.htm#1.2][suggestivity]] that g
13771377
13781378 Some more advanced tutorials [[https://programminghistorian.org/en/lessons/json-and-jq][here]] and [[https://remysharp.com/drafts/jq-recipes][here]].
13791379
1380+ ** use jq . <<<"$var"
1381+ Newlines aren't allowed in json strings, and you might get a jq
1382+ error like:
1383+
1384+ "parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 148, column 99"
1385+
1386+ Sometimes, strings inside json might have encoded newlines like =\n=. If you would use
1387+
1388+ =echo $var | jq .= , bash would interpolate the \n inside the json
1389+ string and when it gets to jq, it's an invalid json.
1390+
1391+ If instead you use =echo -E=, or =<<<"$var"=, things go smoothly.
1392+
1393+ =jq . <<<"$var"=
1394+
13801395** pass flags as a splatted array
13811396 There's quite a bit to chew on this example. First of all, the core
13821397 pattern is to build up your commandline options with an array, and
You can’t perform that action at this time.
0 commit comments