Maja changed the topic of ##bash-crimes to: we bash back | club of folks preoccupied in whether they could, not whether they should | logs https://libera.irclog.whitequark.org/~h~bash-crimes
<sdomi> spiderella: oh, this is really cool, stealing
<misentropy> fwiw you can even for((;thing;)){ ;}
<sdomi> i wish `while :; { ;}` worked...
<sdomi> unrelated: i wrote up a JSON encoder a few nights ago https://git.sakamoto.pl/domi/servfail-sync/src/branch/meow/src/json.sh
<sdomi> currently it's mostly an AST and i'm thinking about fleshing it out a bit more by writing a parser for a JSON-like expression language (so it could automatically generate the form visible in the 2nd file)
<sdomi> if anyone has any suggestions then i'm open to hearing them :pp
<sdomi> (reasoning: `jq` is nice, but for some things (such as arrays) it adds a lot of round trips *or* ugly, error-prone code)
<spiderella> Kinda going in the other direction
<spiderella> sdomi: this line [[ "${_tree[$((_ptr-1))]}" == "object" ]]
<spiderella> You don't need quotes anywhere because there's no pathname expansion on the left side and the right side is literal, and you can remove $(()) because the suffix of an indexed array is an arithmetic context
<spiderella> You also often use _tree[$_ptr] but the $ isn't needed for the same reason
<spiderella> This line _buf+='"'"$1"'"' is identical to _buf+=\"$1\" which is maybe easier to read
<spiderella> The naming scheme needs improving, you have both json_end and json_finish. The latter could be renamed json_print or something
eloy has joined ##bash-crimes
<sdomi> spiderella: good point with the naming scheme (although as i said, not sure if exposing those functions as the *main* interface would be the way to go at all)
<sdomi> as for the rest, most of it are just quirks of my coding style (especially the quotes, I sprinkle them everywhere)
<eloy> thanks for showing on fedi this channel exists sdomi, I had to join immediately :)
<sdomi> ^^