[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Light weight support for JSON

From: Chet Ramey
Subject: Re: Light weight support for JSON
Date: Wed, 31 Aug 2022 11:11:26 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.0

On 8/29/22 2:03 PM, tetsujin@scope-eye.net wrote:
On 2022-08-29 11:43, Chet Ramey wrote:
On 8/28/22 2:11 PM, Lawrence Velázquez wrote:
On Sun, Aug 28, 2022, at 9:24 AM, Yair Lenga wrote:
Wanted to get feedback about the following "extensions" to bash that will
make it easier to work with simple JSON object.  (...)
just to make it easier to build bash scripts that cover the very common use
case of submitting REST requests with curl (checking results, etc), and to
perform simple processing of JSON files.

I do not think bash needs to sprout functionality to support every
data-exchange format of the month.

Loadable builtins are the way to do this

In that case could I suggest providing a simplified, stable programming interface
for loadable builtins?  (I understand this is not a trivial thing, of course.)

I'm not opposed, but it's not going to be a high priority for me. I have
more pressing things to do. That is not to minimize this goal; I simply
put my time into things that impact the maximum number of users.

If someone wanted to make a pass at defining a useful subset of the (quite
large) internal bash API, that would be a start.

As I understand it (having made a few loadable built-ins myself, but possibly a bit ignorant/hazy on the details) - the process involves a fair bit of hands-on with the nitty-gritty of the version of Bash you're building against. A loadable needs to deal directly with implementation details of how Bash handles variables, open file handles, etc., and resulting code (source and binary) is very sensitive
to changes in Bash.

I don't know. I suppose it depends on the complexity of what you're trying
to do. I've not had to update the source in the examples when moving to a
new bash version very often. It's always a good idea to rebuild a loadable
against the bash version you're going to load it into, though.

For me personally I was struggling with questions like, how do I make a loadable module that sets a variable? Sounds simple but it seems to require a fair bit of attention to implementation details of the shell to get it right. What if it's a
local variable? What if it's an array or hash element? And so on.

There are individual functions to do all of these things, but it does
require knowing about them, no doubt.

It would also help
greatly if the shell could internally handle hierarchical data in

That's a fundamental change. There would have to be a better reason to make
it than handling JSON.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]