4 ms·
This is quaint, like an article about how bad opiates are, but it's from before fentanyl. We bash developers are in a really bad spot. If you know one of us, p
by kyleyeats 3y ago
This is quaint, like an article about how bad opiates are, but it's from before fentanyl.
We bash developers are in a really bad spot. If you know one of us, please check on him or her. ChatGPT has enabled our digital hoarding like never before (some of us call it a "scripts folder"-- check for files like build5.sh or *.yml for really bad cases).
I don't know how to write bash. But I'm doing for loops and if statements like never before. I justify it by saying I'm only hurting myself. I've already gone through one hard drive, writing a new index.html over and over and over to the same spot, burning it into the device like the "2" in Sonic the Hedgehog 2 on a 90s CRT.
I lost one of my best friends after I asked him why we don't just use string literals and yaml files for everything. Another when I told him to just put his CSS in a style tag. I can't stop. I can't go back. All I can do is stay away from Makefile people and hope it doesn't get even worse. Don't write shell scripts, kids.
- keepamovin 3y agoHahaha, lol. Where does this come from? I've certainly accelerated my Bash game since ChatGPT came to Earth. Do you know there's a syntax for defaults? ${MY_BIG_VAR:-your_tiny_default} Or that you can completely non-sensically extract the file extension with? file_extension="${1##*.}" How to pronounce that? dollar open-brace 1 pound pound star dot close-brace Reminds me of those codes on the phone system to get service functions...*69#
- blueflow 3y agoThat's called parameter expansion, see https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
- keepamovin 3y agoAlright, when you put it like that, it does make sense. Thanks, that's a great resource! I'm gonna start using ${MY_ESSENTIAL:?"Error: need to supply an essential"}
- rgrau 3y agoYou can also nest those, so this way you can get a value from an argument, or an env var, and if none is set, error. echo "${1:-${env_var:?I need a value for that!}}"
- keepamovin 3y agoOoh, I didn't know you could nest 'em! ChatGPT never told me that! Now we're getting somewhere! :) echo "${1:-${env_var:?I need a value for that!}}" That is awesome! :) Like massively concise construct. I don't know what other language can compete: console.log(process.argv[2] || process.env.VAR || console.error("I need a value for that")); I personally prefer the bash v
- psd1 3y agoIt blows my mind how big a deal argument parsing is in legacy scripting languages (including python). That snippet is concise, but relies on the user supplying arguments in the order you demand. AFAICS, non-trivial scripts require you to loop over arguments, testing against long and short forms of parameters, and shifting if the parameter expects an argument. In Powershell, you define your parameter and apply constraints. Voila: [Parameter(Mandatory)] [ValidateRange(1, 20)] [int]$foo That's it, the entire thing, done.
- blueflow 3y agoIf you call python a legacy scripting language, i'll call Windows (where powershell runs on) a legacy operating system.
- geocrasher 3y agoSure, Windows doesn't have "legacy" like VMS or Unix etc, but it's been in use by every day people longer than any other current OS except for MacOS, which really isn't the same OS it launched as, whereas Windows has maintained backwards compatibility (for better for for worse) for decades. So.. Legacy? Why not.
- kyleyeats 3y agoI did use the file extension thing recently to differentiate between HTML and Markdown files. Very handy.
- sgarland 3y agoNot only is parameter expansion delightfully esoteric, it can replace sed for many applications. Or, as you’ve done, inverse basename. Since it’s a shell built-in, it avoids the overhead of exec. Ever wonder why asdf is slow? Go peek at the source code. This is why. I have a draft PR that fixes it, but there are still some failing tests I need to fix.
- Twey 3y agoHmm, I only see a little bit of bash in asdf, but it's mostly wrappers that I don't expect to have much impact on performance? E.G. https://gitlab.common-lisp.net/asdf/asdf/-/blob/master/make-asdf.sh https://gitlab.common-lisp.net/asdf/asdf/-/blob/master/make-... I always assumed asdf is mostly pure CL…
- twic 3y agoPresumably https://github.com/asdf-vm/asdf https://github.com/asdf-vm/asdf
- forgotpwd16 3y agoReplacing external program calls such as usual sed usage with shell (including bash specific) built-ins was also core in neofetch's design when was made as alternative to screenfetch. Will say that checking dylanaraps, someone worthy to be called a bash wizard, programs is a nice way to learn how to do complex shell scripting.
- yrro 3y agoI can't tell if this is a joke or not. Don't take this the wrong way but doesn't anyone ever read the manual any more? https://www.gnu.org/software/bash/manual/html_node/index.html https://www.gnu.org/software/bash/manual/html_node/index.htm...
- steve_gh 3y agoWe use Makefiles to run our data science pipelines. So my apprentices (yes, we have a data science apprenticeship program with school leavers doing data science degrees on day release) are all familiar with writing and running Makefiles
- zelphirkalt 3y agoI think of Apache Airflow as something like a glorified Makefile. DAG.