February 12, 2023Multiline Commit Messages With `git commit -mWhen you execute git commit on the command line, your specified editor opens and you can create an expressive title and a longer description. That is probably nothing new. You are probably also aware of the shortcut git commit -m <message>, which skips the step with the editor. But there is only room for the title, right? Nope, this is not true. one way It turns out you can use -m multiple times....
February 7, 2022How to Create a Host Dependent Bash ConfigurationI use LXD containers to develop locally. To ease development, I share my home directory with the containers. This is convenient, but brings along a couple of issues on its own, especially for .bashrc modifications, which only apply to the host. e.g. activating bash completion for pipx. eval "$(register-python-argcomplete pipx)" This certainly only works on my host, where the binary is on the path, but not in my development containers....
October 26, 2021How to Quickly Shuffle Some NamesFor the daily standup, we have a random order who starts, who follows next, and so on. How to shuffle a couple of names? Well, obviously, you could fire up a Python repl and use the random library, e.g. >>> from random import shuffle >>> members = ["Me", "TeamMate1", "TeamMate2", "TeamMate3", "TeamMate4"] >>> shuffle(members) >>> members ['TeamMate3', 'TeamMate4', 'TeamMate1', 'TeamMate2', 'Me'] While this works, it is a lot of typing, and a lot of quotes :-)...
June 9, 2021What Is the True Order of Files in a DirectoryThis week I faced a very odd bug at work. A build process failed - on one machine, but not on the other. Identical setup - of course :-/ The build script consists of a bash script, which wraps a call to the C binary. The bash script was innocent. When I had a closer look at the C source code, it turned out there were about 30 lines of code, just dealing with traversing directories and copying files and folders....
April 30, 2021What Is the Meaning of Dollar Dollar in BashI stumbled upon a colleague’s bash script which contained the following line, which in isolation, made not much sense to me. WRKDIR=~/app/work$$ But after some googling and having a look at the complete scope of the script, I finally got it. ... WRKDIR=~/app/work$$ ... mkdir $WRKDIR ... ... ... ... rmdir $WRKDIR $$ is a reference to the PID (process id) it was used to create a unique temporary file All good?...
April 29, 2021How to Run a Bash Script in a Sane WayWhen you never had problems with running/debugging a bash script, you might wonder what I am talking about. Instead of introducing the possible problems, and then the way to counter them, let’s start with the solution. All your bash scripts should probably start with… #!/usr/bin/env bash … wait… it goes on… set -euxo pipefail Wat? Ok, let’s go through the options, one by one. set -e This makes a bash script to stop on error immediately, and exit....
September 7, 2020How to Use the Output of One Bash Command as the Argument of AnotherTIL my TIL is not secure There is a security issue with the following description - at least when you handle sensitive data. see here https://github.com/jugmac00/til/commit/7ea93202cecf97070c8931bbe5a1f64c78d41dcb#commitcomment-42050997 Thanks to Anthony Sottile for reporting! Please see https://unix.stackexchange.com/questions/205180/how-to-pass-password-to-mysql-command-line for a better way to create a login one-liner. How do you use the output of one bash command as an argument of another command? For the virtual machines at my web hosting company, the mysql root password is stored in a config file....