189 points by thunderbong 16 days ago | 36 comments
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.
282 points by woodruffw 18 days ago | 101 comments
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.
356 points by todsacerdoti 27 days ago | 108 comments
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:
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.
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.
63 points by surprisetalk 89 days ago | 58 comments
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.
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.
6 points by todsacerdoti 156 days ago | 0 comments
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…
21 points by thunderbong 159 days ago | 49 comments
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.
40 points by ocean_moist 169 days ago | 0 comments
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.
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.
338 points by lukastyrychtr 203 days ago | 128 comments
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.