Hacker News with Generative AI: Shell Scripting

Hell: Shell Scripting Haskell Dialect (chrisdone.github.io)
This is a copy of the script that generates my blog.
Advanced Shell Scripting with Bash (2006) [pdf] (uniforumchicago.org)
Demystifying the (Shebang): Kernel Adventures (crocidb.com)
From my first experience creating a shell script, I learned about the shebang (#!), the special first line used to specify the interpreter for executing the script:
Any program can be a GitHub Actions shell (yossarian.net)
In GitHub Actions, you can use the shell keyword to specify the shell that runs a given run: block. This keyword is optional for workflows but mandatory for action definitions.
Techniques Hacker News Uses to Create Great Shell Scripts (nochlin.com)
After publishing my previous article on how I create a great user experience for shell scripts, the Hacker News community provided valuable feedback and suggestions. I've compiled these insights into six additional techniques to further enhance your shell scripts:
Setup QEMU Output to Serial Console and Automate Tests with Shell Scripts (2019) (fadeevab.com)
While struggling to automate QEMU guest (communicate and control with the shell scripts), I faced a lot of incomplete, partially working solutions around the Internet. Now, I've got a pretty decent collection of working recipes to tune up a QEMU guest, so I decided to organize all that stuff here, and it could be definitely useful for anyone else.
Bash-ini-parser: Advanced bash INI parser library (github.com/lsferreira42)
A robust shell script library for parsing and manipulating INI configuration files in Bash.
Self-contained Python scripts with uv (dusktreader.dev)
You can add uv into the shebang line for a Python script to make it a self-contained executable.
Safe Shell String Interpolation (samwing.dev)
Let's take the toy problem of getting the user's name and printing out a rainbow greeting banner. An inexperienced developer might solve the problem like this:
A 6502 emulator written in busybox ash (treehouse.systems)
Xdg-ninja: checking your $HOME for unwanted files and directories (github.com/b3nj5m1n)
A shell script that checks your $HOME for unwanted files and directories.
How to add a note above your files when running `ls` (github.com/gkamer8)
How to create an alias of `ls` that displays a .note file, if it exists.
I shouldn't of made this. Another direnv alternative for no reason (willwa.de)
I hate having to do this. But I have.
Prefer tee -a, not >>, in CI (huonw.github.io)
Shell scripts sometimes have to append data to a file. Redirecting output with >> is the conventional way and works fine, but using tee -a instead is a usually better default, especially in continuous integration. It’s just as easy and gives automatic introspection: the same value is printed to stdout and so appears in normal logs too.
Shell-ish scripting in Go with ease (github.com/bitfield)
script is a Go library for doing the kind of tasks that shell scripts are good at: reading files, executing subprocesses, counting lines, matching strings, and so on.
Find the oldest line in your repo (milofultz.com)
This is how all my projects go. I get a wild hare and then figure out how I can make a shell script to do it. Thanks to some help from people online, I was able to make a script that listed out the oldest lines in a git repo. Kind of fun to see what legacy stuff is still around.
Today I learned that bash has hashmaps (2024) (xeiaso.net)
Hashmaps (associative arrays) are a great way to store a bag of key-value data. At work I was writing something that needed me to spawn a bunch of GPU instances, GPU availability is spread out by region and GPU type. I wanted to store a mapping of GPU kind to region name and for some reason I thought it would be a good idea to do it in bash.
Fish 4.0: The Fish of Theseus (fishshell.com)
About two years ago, our head maintainer @ridiculousfish opened what quickly became our most-read pull request:
Populating env vars using 1Password (coryd.dev)
I love automating things and — with that impulse entirely unchecked — I've written up a shell script to make setting this site up for local development even simpler.
Biggest shell programs (github.com/oils-for-unix)
TIL: Some surprising code execution sources in bash (yossarian.net)
I ran across two surprising sources of code execution in bash (and probably other shells) recently.
A Second Search for Bash Scripting Alternatives (monzool.net)
SHELL SCRIPTING IS something most programmers will encounter often – especially if doing dev-ops, automation and general Linux work. Unfortunately we are mostly stuck with bash. There surely must be better alternatives…
Resolving a mysterious problem with find (johndcook.com)
Suppose you want to write a shell script searches the current directory for files that have a keyword in the name of the file or in its contents. Here’s a first attempt.
Yosild: A single shell script that builds a full, minimal Linux distribution (jm.iq.pl)
Yosild is a single shell script that builds a full, minimal Linux distribution, based on BusyBox. It compiles the latest stable kernel and the latest stable version of the BusyBox. This script can prepare minimalistic Linux system for devices with little hardware resources. Yosild Linux needs just 70 MB RAM and 40 MB storage size. yosild.sh requires minimal Debian or Ubuntu distro to run with the architecture compatible with the target device.
Learn Awk in Y Minutes (learnxinyminutes.com)
AWK is a standard tool on every POSIX-compliant UNIX system. It’s like flex/lex, from the command-line, perfect for text-processing tasks and other scripting needs. It has a C-like syntax, but without mandatory semicolons (although, you should use them anyway, because they are required when you’re writing one-liners, something AWK excels at), manual memory management, or static typing. It excels at text processing. You can call to it from a shell script, or you can use it as a stand-alone scripting language.
85% of Cursor AI in a Shell Script and Good Prompting (rohan.ga)
This is an example workflow of how to integrate LLMs into your software dev.
NGS – Next Generation Shell (ngs-lang.org)
Next Generation Shell is a modern programming language that focuses on "DevOps"y use cases.
Abuse ZSH Parameter Expansion to Expand GNU-Style Arguments (blogspot.com)
This method offers exactly one benefit: the target platform I was working with for this project was mingw under Windows and, like WSL1, it had this very painful performance issue when a shell had to create a sub-shell -- basically, any time you $(run something) and that means "if your function returns anything except for an integer", it's going to have a serious cost to place that into a variable the convenient way.
Whence '\n'? (rodarmor.com)
If you do just foo, the following justfile will write a single byte 0x0A to a file named bar:
A Tour of Hell – Shell scripting Haskell dialect (chrisdone.com)
This set of slides sketches out the implementation of Hell, in technical detail. I do tend to switch between the slides, old code, and the present code, so bear with me. It's more about the ideas. If you want to see a complete implementation, the complete implementation of Hell is one file, which you can look through easily.