This article on the IBM Developer site has a history of shell evolution. It isn’t anything novel, but the nice family tree diagram and comparison of scripts in different shells are illuminating. They don’t discuss zsh. The zsh FAQ outlines a brief history of that shell. In that FAQ, zsh is described as closest to the Korn shell (ksh). There are also some options to make zsh act like other shells like CSH_JUNKIE that makes it more compatible with csh.
Read Morezsh on FreeBSD
After some deliberation, experimentation and research, I’ve decided to go with zsh as my interactive shell on FreeBSD. zsh has nice modern shell features that I’m missing when I’m at the shell prompt in sh, the default FreeBSD shell. Simple stuff like !! or !$ that I tend to use quite a bit. I’m most familiar with bash, but that seems to cut against the grain of FreeBSD. Also, zsh is the default on MacOS now so I use it quite freqently there.
Read MoreUsing an API in bash
I’ve continued to work on my create server script from time to time. The latest update was checking that we could connect to the Hetzner API using the key that is given and bailing out if we cannot. curl is a interesting and useful tool. curl has been around since 1996 and it is ubiquitous. curl is simple to use: curl https://l10systems will download this website. It’s also very powerful with many, many options.
Read MoreHetzner server creation script revisited
I’ve written a couple of scripts to create servers on Hetzner over the years to facilitate small projects and experiementation. My older scripts used the Hetzner CLI which was fine but I wanted a version without that dependency or any other dependencies. So, I rewrote it in bash without the CLI by using curl to call the webservices. Initially, I had used jq to work with the returned JSON but since the requirements were pretty simple, I refactored that out.
Read MoreAwk lives
Awk is pretty ancient (1977) but is a nice tool to know for text processing. I’m no expert, but I do use Awk from time to time for various simple tasks. A second edition of The AWK Programming Language is coming out in October and it looks interesting based on what I read through on O’Reilly. This article shares some of the highlights including a chapter on data analysis and an updated simple version of Make in Awk.
Read MoreBash template
I’ve not been doing much bash scripting recently. So, when the need arose to create some simple scripts, I did some quick refresh on some things that make scripting better/faster/easier. A nice resource I found had some opinionated advice on bash and a really nice template that I’m going to use as a starting point for my scripts. It looks like this: #!/usr/bin/env bash set -o errexit set -o nounset set -o pipefail if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace fi if [[ "${1-}" =~ ^-*h(elp)?
Read MoreShellcheck
Shellcheck is a handy tool for working with bash scripts. It does a nice job of doing a sanity check of bash script against a set of rules and is simple to use. As a quick example, consider this very simple script: #!/bin/bash A="some value" echo $A echo "${A}" echo "${B}" This script will do what you think it should but has a few problems. Running shellcheck on this script produces some simple output with suggestions to improve the script:
Read MoreCloud command line
I use AWS occasionally and on those occasions I almost always discover something new and interesting. Today’s discovery is fairly prosaic but interesting in a number of ways: AWS CloudShell. I’m running a little behind the times here as this has been around for well over a year and I’m somewhat familiar with the GCP and Azure versions of the same basic thing. AWS CloudShell is, as the name says, a browser based shell that is integrated into AWS.
Read MoreAlias for post creation
Hugo has worked out well for creating this blog. To make it even easier, I wanted to make creation of new posts simpler. To date, I’ve basically looked at the last post and then created the next one in sequence by using the command hugo new ~/myblog/post/content/091.md, for example. To automate that some, I created a bash alias that looks like: alias newpost='hugo new ~/myblog/content/post/$(printf "%03d.md" $(expr $(basename $(ls ~/myblog/content/post/ | tail -n 1) .
Read MoreBlog restructure
I felt the need to renumber my blog posts file names from a date (e.g., 20211222.md) to a sequence (e.g., 087.md). Hugo does a nice job of putting posts from the same date into a folder labeled for that date, so the date numbering was restrictive if I wanted to create two posts on one day (admittedly, a rarity). A number also is a nice way for me to keep track of how many posts I’ve written since I started doing this again.
Read More