|
|
|
|
|
by bsdetector
787 days ago
|
|
JSON is not immediately usable by and is cumbersome to parse correctly in a shell. A simple line-based shell variable name=value format works unreasonably well. For example: # ls --shell-var ./thefile
dir="/home/user" file="thefile" size=1234 ...
# eval $(ls --shell-var ./thefile); echo $size
1234
If this had been in shells and cmdline tools since the beginning it would have saved so much work, and the security problems could have been dealt with by an eval that only set variables, adding a prefix/scope to variables, and so on.Unfortunately it's too late for this and today you'll be using a pipeline to make the json output shell friendly or use some substring hacks that probably work most of the time. |
|