Need help?
<- Back

Comments (34)

  • adityaathalye
    IMO, a scripting language is the lesser contributor to the power of shell scripting. My ranked-order is:1. Universal Inter-Process Interface: Arbitrary program composition via the Standard Input / Output / Error interface, and "everything is a file" abstraction... None of the rest is possible without some such core design decision ("everything is an object" is the fraternal twin).2. Widespread standard utilities: The broad availability of core util tools designed to cooperate via the same abstraction is a close second. Along with some default scripting language, that is also built for the same computing model.3. Language of choice: Important for ease of access, but a distant third in terms of raw power, be it bash, perl, awk, node, clojure (babashka) etc. That's icing on the cake, because if one had no choice in the matter, the shell program would still be awesomely powerful. Proof is in the pudding---"scripts that matter" are always /bin/sh.Generally speaking, the pain of learning to avoid sh and bash footguns is primarily a matter of some basic research reading: manuals, lore, and warnings (I love BashPitfalls). Well, either that, or learning the hard way by copy-pasting code, and if luck runs out, rm -rf ing something you shouldn't have.There is no substitute to taking the day or so to read the manual, so you know it's a lot, but it ain't magic, and you can eat that elephant one bite at a time, at your own pace. Seriously... the wall-clock time of trial and error with BashPitfalls (about a day or so), is nothing compared to learning to use---and then having to re-learn every so often---the python or node or whatever ecosystem without losing it. Besides, the former knowledge is stable and so are the programs --- my Bash code will keep working the same way, forever, practically speaking.
  • happyPersonR
    I’m going to say something … and it might trigger folksLearning and getting good at shell scripting is something that takes a while usually. I would recommend that people new at shell scripting actually try to use Python instead writing shell scripts where possible.I’ve seen people not use traps, not know when to use set properly, xargs if you don’t know what you’re doing with it is just a giant foot cannon, and folks new at shell scripting don’t know how to debug running shell processes.They may have learned some or all of these things for python?(please? )
  • utopiah
    Right, and I would also argue that scripting goes way beyond the terminal.Scripting in the terminal can manipulate windows too (e.g. xdg-open with KWin), or send notification locally (e.g. notify-send) to any devices (again or ntfy), or open dialogs (e.g. kdialog), or controlling other devices (e.g. curl to HomeAssistant API) so indeed it opens up an entire new world of possibilities... and it's combinatorial.Also for another bit of context, scripting works ... on the weirdest newest devices, e.g. a Meta Quest on Android thanks to Termux. If there is an OS there is surely a terminal in there somewhere, and if there is, you can script on it. So... scripting isn't "just" for your desktop or a remote server, it's everywhere.
  • BeetleB
    My problem with shell scripting is I've learned it many times, and forgotten it an equal number of times.Thank God for LLMs.
  • necovek
    I was pretty close in guessing what they believe was "wrong" (or really, superfluous) with their initial shell script example.I'd even drop the "if" from their footnote version, and go with simply npm install || (echo "boom" && exit) (Not exactly equivalent because there won't be an "exit" if echo fails, but it's my preferred instict over ";") Also, "(" starts a subshell, if we are being pedantic.
  • necovek
    On the higher level question in the article of why do people not use their main languages for basic file and command management?I believe the answer is the same as to why Python remains hugely popular despite all the well-documented shortcomings: batteries included.Shell languages include so many neat and concise ways to execute commands, deal with their input, output and exit codes, allow simple traversal of deep directory structures with globs and advanced tools like 'find' or 'xargs', that everything else is very unergonomic.And niche by default (until it gets used widely enough), so even your LANG-OF-CHOICE-expert you recruit, they will not know a thing about that shell-focused library in LANG-OF-CHOICE.
  • mplanchard
    Totally agree, and also this was one of the most powerful aspects of using nix development environments: when everyone is guaranteed to be on all the same (recent) versions of bash, make, awk, sed, and any other system deps, you can confidentially write your scripts knowing the whole team can use them, without having to deal with Mac users’ scripts breaking because their bash is old, or because somebody doesn’t have jq installed, or whatever.
  • carra
    I was sure this article would be about how we tell computers to do things now (writing prompts to an AI in plain English). I was wrong. Interesting nonetheless.
  • ccapitalK
    TIL that the duckdb REPL supports reading json files (https://duckdb.org/docs/current/data/json/overview). This might actually be useful the next time I need to investigate a massive json file (`jq` can only go so far).
  • Sharlin
    There is, of course, a programming language designed to do shelly things as succinctly as a shell script: Perl.
  • ZeroDayDreamer
    That philosophical point about what it even means to "tell a computer to do things" is a good one. Sure, clicking around in a GUI is also telling the computer what to do. But there's a huge difference between using someone else's abstraction and building your own from scratch. The article is about that second part - the ability to throw stuff together however you want. With a GUI, you're stuck with whatever the designer thought of. With a shell, you can build just about anything
  • JimA
    I also assumed this was going to be an intro to using AI as an interface for your local device. I love terminal use and scripting, but after experiencing what it's like to tell an AI to do something in plain language and it does it I'm also excited about that future. There won't be a need to memorize obscure "commands" or syntax when an AI can directly do what you ask or even provide a script for you. We might might occasionally miss the old days when we had a unique skill set, but progress marches on.
  • jeremyjh
    Good advice. I've gotten a ton of utility out of my shell without learning very many tools particularly well.If you take nothing else away from this, memorize the syntax of one-liner for loops, it has saved me so many times.
  • weikju
    Nice article about actually learning stuff and putting this knowledge to use together. Not with AI but with one’s own brain.
  • fyredge
    I disagree on the premise that the author is "using" shell. Often when reading about why the command line / shell is better than GUI, the salient advantage comes down to one thing, scripting. Yet scripting in an IDE, which is a GUI, is a ton easier than in vim, simply because the surface for discovery of actions is much more transparent.If scripting were to be excluded, the belittling of GUIs falls a bit flat. I'd like to see graphic design work be done via CLI.
  • anon
    undefined
  • applfanboysbgon
    Your next homework assignment is to write your own scripting language that emits asm. Then you'll be one step closer to understanding what it really means to tell your computer to do things!
  • altmanaltman
    Why are we assuming using the terminal is the only way of "telling a computer to do things"? Every way you interact with a machine, you are telling it to do things in theory.For example> At a fundamental level, I wasn’t able to tell my computer to accomplish anything that involved logic or stitching together multiple programsHow can that be true if you are telling it to boot on into a os? It doesn't involve logic? Or stiching together multiple programs?Using a shell =\= telling a machine what to do on a broad level. You are just using the abstractions provided by the os. If you mean get better at shell so you can use it more efficiently than okay cool but that doesn't someone who uses a GUI doesn't "tell" the machine what to do as much as you.
  • aldricarchive
    [flagged]