Hacker News new | ask | show | jobs
by jpgvm 713 days ago
{"password":"hunter2"}

A man of culture I see.

This looks really useful where you don't want to introduce another scripting VM just to spit out some JSON, i.e I have used Ruby a lot for this in the past.

I can see myself using this in container init scripts and other very low dep environments to format config files from env vars etc.

3 comments

I wouldn’t do that to my users; the happy path here is nice, but the unhappy path seems very likely to end in garbled bash errors that are impossible to track down.

As a user, I’m fine with embedding a reasonably small VM to handle the configs; disk space is cheap. Better yet would be a compiled binary that handles it, but that feels like asking a lot of maintainers.

There’s a lot of surface area for someone to mis-quote stuff in their environment and generate unintelligible bash errors.

Or that may be just me; I hate bash in general, so maybe it’s just that bleeding over.

How did you guess my password?!?!

This is just the kind of use case I had in mind. Something I've considered is publishing a mini version with only the json.encode_string function, as that's enough to create an array of JSON-encoded strings and use a hard-coded template with printf to insert the JSON string values.

That would be a fraction of the overall json.bash file size.

RIP bash.org!