5 ms·
Not the person you replied to, but - yes, `head file.txt` is perfectly reasonable, as are a few other use-cases like `grep`/`sed`-ing. But when you go beyond "p
by scubbo 5y ago
Not the person you replied to, but - yes, `head file.txt` is perfectly reasonable, as are a few other use-cases like `grep`/`sed`-ing. But when you go beyond "processing streams of lines of text" and start having to introduce conditionals, maps, or functions, the syntax is (for me, at least) opaque and easy to make mistakes in.
- marginalia_nu 5y agoIsn't that also a case against learning new programming languages?
- vore 5y agoI think bash has a lot of gotchas due to its original purpose, and it's definitely more error-prone to write bash scripts than to e.g. write Python scripts, so that should be a consideration. Ideally we should all try to more programming languages that are harder for us to shoot ourselves in the foot with, rather than easier ;-)
- marginalia_nu 5y agoI think considering the purpose of the language, it does rather well. It's really easy to spawn and pipe processes, far more so than in almost any alternatives. Like it's so easy that it's easy to forget that this is like a 5-10 line overhead dance to launch and read from a process in most languages. The problem usually come when you attempt to use it for nontrivial programming. But that just not what it's for, any more than the difficulty in building an OS kernel is a legitimate complaint against PHP.
- vore 5y agoI think this is what the post you were replying to is saying.
- chasil 5y agoStephen Borne famously disliked C, and much preferred Algol. This is important to know in the context of what you are saying. The Algol structures in the Borne shell are the most incongruous parts of UNIX. https://research.swtch.com/shmacro https://research.swtch.com/shmacro
- chasil 5y agoI will just leave this here. "I am a strong believer that Bourne-derived languages are extremely bad, on the same order of badness as Perl, for programming, and consider programming sh for any purpose other than as a super-portable, lowest-common-denominator platform for build or bootstrap scripts and the like, as an extremely misguided endeavor. As such you won’t see me spending many words on extensions particular to ksh, Bash, or whatever other shells may be popular." http://www.etalabs.net/sh_tricks.html http://www.etalabs.net/sh_tricks.html
- marginalia_nu 5y agoI think it's easy to sort of gloss over how good shell scripts are at the sort of things they actually are good at. Consider this: for f in *png; do convert $f $(echo $f | sed 's/png$/webp/'); done This is like at least a screen of code in in most languages, you get that sinking feeling where you need to fork a process and deal with its lifecycle and deal with some standard library to list files and don't forget to close the file handle for the directory and god forgive if you run a program with actual output then you need to read from a pipe. Like, geesh, do I have to write a whole program to convert a few files? In a shell, it's just something you type up because you needed to convert a few files. Don't get me wrong, shell scripts are extremely bad at most things involving non-trivial branches, long-lived state, really most things other languages are good at, but man are they ever good at some things most programming languages are bad at.
- leephillips 5y agolee@sp3tmp1:ls *.png 'a b.png' c.png lee@sp3tmp1:for f in *png; do convert $f $(echo $f | sed 's/png$/web'); done convert-im6.q16: unable to open image `a': No such file or directory @ error/blob.c/OpenBlob/2924. convert-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/575. convert-im6.q16: unable to open image `b.png': No such file or directory @ error/blob.c/OpenBlob/2924. convert-im6.q16: unable to open image `b.png': No such file or directory @ error/blob.c/OpenBlob/2924. convert-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/575. convert-im6.q16: no images defined `b.webp' @ error/convert.c/ConvertImageCommand/3229. [etc.] I think you could be making a more complicated point.
- suifbwish 5y agoBy that logic shouldn’t we also stop using programming languages that aren’t threadsafe? Segfaulting could be prevented if C++ wasn’t so esoteric.