|
|
|
|
|
by ilyash
407 days ago
|
|
Opinion. Likely controversial. The fact that we need jq highlights that we are missing this functionality in shells. I argue that these days (nested) structured data is as basic requirement as having scalars, arrays and associative arrays (which bash has). It hurts my eyes seeing five line of assignment to variables where each one runs jq to extract that particular field from a data structure. More at "jq is a symptom" - https://ilya-sher.org/2018/09/10/jq-is-a-symptom/ Related and might be interesting - "JSON tools for command line" - https://ilya-sher.org/2018/04/10/list-of-json-tools-for-comm... |
|
Commands with support would detect the shell and output an SQL schema along with insert statements containing the result of the command on a special file descriptor. These would be applied to a newly created 'history#' table and aliased to the 'result' table. The standard output of the command would still be displayed as it is now.
You could then do things like 'ls' and then 'select name,size,owner from result where size > 1024 and owner != 0;' And continue to run queries against the last result until it's replaced by a new command. Or run queries against the 'history#' table or multiple tables to join results from multiple independent commands.
With support for JSONB in most SQL engines this would provide a nice mechanism for working with any sort of nested data structure from any given program or from plain JSON files if required.