News for hackers. Stuff that matters.
Re:Show HN: Jb / json.bash – Command-line tool (and bash lib... by h4l on Wednesday July 03, 2024 @02:52PM (#40868923)
Two main situations I think. The first is just interactive use in any shell to encode ad-hoc JSON. If you have a next-gen shell which can handle structured data directly, then you probably don't need it.

Second is situations where you'd rather not add an additional dependency, but bash is pretty much a given. For example, CI environments, scripts in dev environments, container entrypoints. Or things that area already written in bash.

I don't advocate writing massive programs in bash, for sure it's better to turn to a proper language before things get hairy. But bash is just really ubiquitous, and most people who do any UNIX work will be able to deal with a bit of shell script.

Re:Show HN: Jb / json.bash – Command-line tool (and bash lib... by IshKebab on Wednesday July 03, 2024 @04:05PM (#40869530)
> Second is situations where you'd rather not add an additional dependency, but bash is pretty much a given. For example, CI environments, scripts in dev environments, container entrypoints. Or things that area already written in bash.

Is this tool not an additional dependency?

> But bash is just really ubiquitous

Biggest crime of the Unix world probably.

Re:Show HN: Jb / json.bash – Command-line tool (and bash lib... by h4l on Thursday July 04, 2024 @01:02AM (#40872433)
> Is this tool not an additional dependency?

It is, but if you already have bash, adding another shell script isn't much of a jump. e.g. I'd feel OK about committing jb to another repo for use from a .envrc file to set up an environment, whereas committing a binary would not feel good.

> Biggest crime of the Unix world probably.

Sorry if I'm perpetuating this! :) My take is that problem is not with bash, the problem is that it's hard for more advanced tools to replace it.

Re:Show HN: Jb / json.bash – Command-line tool (and bash lib... by kazinator on Friday July 05, 2024 @11:08AM (#40883431)
> Is this tool not an additional dependency?

"Dependency" generally means "external dependency".

It's only a dependency if your solution's build process fetches it from its upstream repo. (Or worse: it's just mentioned in some manual build instructions as one of the things your solution needs.)

This is small enough to copy into the source tree of your solution, in which case it's no longer a dependency.

Re:Show HN: Jb / json.bash – Command-line tool (and bash lib... by wavemode on Wednesday July 03, 2024 @06:35PM (#40870659)
I agree with the interactive usecase.

But for when you don't want an extra dependency, awk and perl are better than bash and just about as ubiquitous. (I might dare to say more ubiquitous, since MacOS in particular ships with an ancient version of bash that can't even use this jb tool. But the versions of awk and perl it comes with are fine.)