5 ms·
Awesome looking tool. One thing I noticed, however: $ false; echo success@$? | jo {"success":true} i.e. jo's translation of integers to booleans does
by dansimau 11y ago
Awesome looking tool. One thing I noticed, however:
$ false; echo success@$? | jo
{"success":true}
i.e. jo's translation of integers to booleans does not match that of a typical shell.
- kbd 11y agoBecause the shell substitutes the return code before passing to jo, jo sees 'success@1'. How do you expect jo to know where the 1 came from to change its interpretation? Edit: or you're saying jo should always consider 0 true and 1 false to match shell return code conventions?
- dansimau 11y ago> How do you expect jo to know where the 1 came from to change its interpretation? It was merely an observation. Of course, one can simply negate the value before passing it to jo. jo looked as though it was for use in the shell though, so I was curious as to the design decision here.
- jpmens 11y agoI intended True to be, well, TRUE (1). TBH I didn't consider a shell's success (0) as true, though I do see your use-case.
- kbd 11y ago> It was merely an observation... jo looked as though it was for use in the shell though, so I was curious as to the design decision here. I think it makes sense how it is, since if I typed "success@1" I wouldn't expect that to output "{success: false}" but I definitely appreciate your point about a case like "success@$?". > Of course, one can simply negate the value before passing it to jo. What's the shortest way to do that? This? echo success@$(test $? -ne 0; echo $?)
- kbd 11y agoShortest way: $ false; echo success@$((! $?)) success@0