5 ms·
Why in the world would you even reach for plain text when you can get JSON or YAML? Dude, you have machine-processable formats to work with and you figured you'
by pdimitar 5y ago
Why in the world would you even reach for plain text when you can get JSON or YAML? Dude, you have machine-processable formats to work with and you figured you'll be clever.
I'd definitely scold him if he was my colleague.
And I seriously don't care about bash weirdness. It's an endless rabbit hole. Happily we have `shellcheck` nowadays but even with that I do my very best to avoid scripting beyond the most basic needs because I've been bitten by unexpected behaviours many times.
Will it all make sense if you work with it full time for 6 months? I am sure it will but most of us will never get such big stretches of uninterrupted bash practice so I just prefer to work around it as much as I can.
It's kind of like GIT: if you go all-in you'll emerge very enlightened. But most programmers just want to get in, do their rare-and-hard-to-remember-thing and get out. That's why most of us have to Google various GIT incantations every time we need them.
- hnlmorg 5y agoIn 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