Comment

Comment by metadat

This is incredibly high-quality BASH programming, as a fellow bash freak I am studying this code, and even I am learning some new techniques.

https://github.com/h4l/json.bash/blob/main/json.bash

You've boiled it down to a set of very elegant constructs. Respect. Thank you @h4l, this is badass.

I hope you follow up with a golang or rust implementation, that would really be something else.

p.s. I noticed the following odd behaviors with escaping delimiters (e.g. "="), is there a way to get an un-escaped equal sign as the trailing part of a key or leading part of a value?

  $ docker container run --rm ghcr.io/h4l/json.bash/jb msg=Hi
  {"msg":"Hi"}
  $ docker container run --rm ghcr.io/h4l/json.bash/jb msg=\=Hi
  {"msg=Hi":"msg=Hi"}
  $ docker container run --rm ghcr.io/h4l/json.bash/jb "msg=\=Hi"
  {"msg":"\\=Hi"}
  $ docker container run --rm ghcr.io/h4l/json.bash/jb "msg\==\=Hi"
  {"msg\\=\\":"Hi"}
  $ docker container run --rm ghcr.io/h4l/json.bash/jb "msg\\==\=Hi"
  {"msg\\=\\":"Hi"}
  $ docker container run --rm ghcr.io/h4l/json.bash/jb "msg\\===Hi"
  {"msg\\=":"Hi"}
parent metadat 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton