3 ms·
So, in conclusion it's a hack... but, it's also incredibly robust. It doesn't hurt, and we acknowledge there are cases where it could help. It's idiomatic enoug
by chunkyks 6y ago
So, in conclusion it's a hack... but, it's also incredibly robust. It doesn't hurt, and we acknowledge there are cases where it could help. It's idiomatic enough that literally everyone who's done a nontrivial amount of scripting is familiar with it.
At some point, "decades old idiomatic hack that increases robustness" stops being a hack and becomes an idiomatic way to increase robustness.
A better conclusion would be "yes, keep using it".
- m463 6y ago> So, in conclusion it's a hack... but, it's also incredibly robust. You know, shell scripts are a hack. I really wish there was a middle ground between shell scripts and say python. Python has proper lists and hashes and loops and can manipulate paths with spaces or quotes or unicode. It doesn't get dragged down by the escape-an-escape-within-a-regex nonsense that makes things undecipherable. or ${VAR:-foo} or ${VAR##ugh} But python is a bit fumbly when it comes to invoking external programs. try: ... subprocess.bleh except: ... ugh.
- zokier 6y agoPerl?
- acdha 6y ago> But python is a bit fumbly when it comes to invoking external programs. try: ... subprocess.bleh except: ... ugh. I actually tend to prefer that these days — if I write shell I'm tossing in "set -e -u -o pipefail" anyway and subprocess's newer APIs end up being cleaner when you need to do anything non-trivial for error handling (I usually end up with one `try:` block for most of the program and maybe one or two `except: cleanup(); raise` blocks. Having the logic be clean and consistent saves you so much time when you revisit that program a month later. The biggest wins I've seen from quoting external program arguments — either not needing to do so at all or passing things cleanly through shlex.quote makes it so much easier when you have the possibility of any special characters in arguments.
- chubot 6y agoThat's one good way to describe Oil: a middle ground between shell and Python. e.g. this post has the slogan that it's "for Python and JS programmers who avoid shell". http://www.oilshell.org/blog/2020/01/simplest-explanation.html http://www.oilshell.org/blog/2020/01/simplest-explanation.ht... Oil has hash tables, and can manipulate paths with spaces -- in fact the latest blog post is about that! http://www.oilshell.org/blog/2021/04/simple-word-eval.html http://www.oilshell.org/blog/2021/04/simple-word-eval.html Also the same blog post mentions that we should get rid of ${VAR##ugh}. Help wanted :)