3 ms·
In fairness to the author, he does mention the JSON and YAML at the end of the blog. Though he does still completely misunderstand how bash is handling strings
by hnlmorg 5y ago
In fairness to the author, he does mention the JSON and YAML at the end of the blog. Though he does still completely misunderstand how bash is handling strings in his conclusion:
> Bash cleans up extra spaces when writing to stdout unless you use variable quoting.
Nope. Bash parses the spaces as parameter delimiters if you don't quote:
$ echo "a b c" # is equivalent to echo("a b c") in C
$ echo a b c # is equivalent to echo("a", "b", "c") in C
Also remember that variables are expanded on the command line, not passed to the calling executable (the calling executable wouldn't know what to do with a $variable so any variables need to be expanded on the command line).
- pdimitar 5y agoSee, this is exactly what I mean. :D I would misunderstand as well. Processing plain text is ambiguous and we all carry our own assumptions along for the ride. Bash's traditional huge (and badly formatted on the web) help pages don't help matters as well. I'd think in 2021 we'll have an official "TL;DR: bash gotchas" but I guess not.
- hnlmorg 5y agoIn the shell I'm writing you get a preview of what the command is before it's sent so its definitely possible to write better shells. It's not POSIX though and there will always lie the problem. You might build a better shell but few will use it