4 ms·
YouTube link for video if it's broken for others and not just me: https://www.youtube.com/watch?v=olH-9b3VJfs https://www.youtube.com/watch?v=olH-9b3VJfs Some
by packetlost 2y ago
YouTube link for video if it's broken for others and not just me:
https://www.youtube.com/watch?v=olH-9b3VJfs https://www.youtube.com/watch?v=olH-9b3VJfs
Something I learned recently is that the Bourne shell (and by extension, bash and POSIX's sh) have syntax inspired by Algol 68 (source [0]), which explains some of the funkyness. One thing I've been doing recently is writing scripts in rc, the default shell for plan9. It's a bit saner syntax-wise IMO. Versions linked against readline have file-based completion, but it's otherwise not quite robust enough for me to switch away from fish as my default, but it has some things I prefer over both bash and fish.
I encourage people to give rc and awk a shot, they're both small and learnable in an afternoon!
[0]: https://doc.cat-v.org/plan_9/4th_edition/papers/rc https://doc.cat-v.org/plan_9/4th_edition/papers/rc
- Rendello 2y agoThe Bourne shell was hilariously written in horribly deformed C resembling ALGOL by way of macros: https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/mac.h https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh... https://news.ycombinator.com/item?id=22191790 https://news.ycombinator.com/item?id=22191790
- packetlost 2y agoThat's amazing
- Joker_vD 2y agoInfluence of Algol 68 doesn't even really explains requirement of semicolons (or equivalently, new lines) in weird places. while false do echo 1 done if false then echo 1 fi argubaly should just work, the presence of do/then/done/fi keywords makes semicolons quite superfluous yet the correct forms are while false ; do echo 1 ; done if false ; then echo 1 ; fi Which is strange, because Algol's grammar actually prohibits ; before ELSE, FI, and OD keywords yet the Bourne shell requires them!
- Koshkin 2y agoWell, to be fair, the use of semicolons in the shell has nothing to do with their use in other languages, here they are simply line separators.
- jorvi 2y ago> One thing I've been doing recently is writing scripts in rc, the default shell for plan9. It's a bit saner syntax-wise IMO I'll stand on the point that if you're gonna forego (ba)sh compatibility, 95/100 times you might as well write Python scripts. Shell syntax generally sucks, and the only reason we still roll with it is legacy code, universal compatibility, and pipes.
- packetlost 2y agoAs someone who worked with Python professionally for like 8 years, I wholeheartedly disagree with this. Python is an ok scripting language but it's an awful command script language. The extra ceremony to just invoke another command is a complete non-starter IMO. Ruby handles the cases where a shell script makes sense way better than Python does and I still wouldn't pick Ruby. Rc's syntax is better than ba(sh), which is the point: you get things like pipes and easy commands without some of the cruft.
- setopt 2y agoAs someone who also has written my fair share of Python, I completely agree. Piping and subprocess handling are my two main complaints as well. Managing concurrent processes is arguably also easier in shell scripts, in that you can just append “&” to run stuff in the background and “wait” to sync.