From 7a6d98c213256a9e0fbb1352c12ecfebdbf1a903 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Mon, 19 Jan 2026 17:13:01 -0500 Subject: [PATCH] Deploying upstream@dd1c58a0d1ff2004d7a9d6b4ed18f7b147c0046e: Clarify a point --- 2026/01/19/This-Old-Tool-cmdarg/index.html | 2 +- atom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/2026/01/19/This-Old-Tool-cmdarg/index.html b/2026/01/19/This-Old-Tool-cmdarg/index.html index e9eb728..cab1422 100644 --- a/2026/01/19/This-Old-Tool-cmdarg/index.html +++ b/2026/01/19/This-Old-Tool-cmdarg/index.html @@ -508,7 +508,7 @@
  • You might need to accept an argument that defines a key=value pair, now you have to parse that pair, break it apart, and store them separately (depending on your use case)
  • You might need to accept multiple values for a given argument and build a list. How do you do this? Do you accept a string with space separated items? Do you accept the same argument over and over? How do you store this in your script’s internal state?
  • -

    I feel the same way about bash that I do about C: it’s basically the perfect language for gluing tasks together on a unix system. But this particular task in bash has always managed to really piss me off, because frankly, we can do so much better than what we are doing right now. This is one of the big reasons why people will abandon bash for the kinds of glue tasks it’s so good at, and move to something like golang, because there’s not a great interface between the user and the script for configuring options at runtime. Parsing arguments can be downright unfriendly to the user, in fact, let alone to the developer. It doesn’t have to be this way! There’s no reason why Java and Python and Ruby and Golang and literally every other language out there can have high quality argument parsing libraries but Bash can’t have them.

    +

    I feel the same way about bash that I do about C: it’s basically the perfect language for its domain (in bash’s case, gluing tasks together on a unix system). But this particular task in bash has always managed to really piss me off, because frankly, we can do so much better than what we are doing right now. This is one of the big reasons why people will abandon bash for the kinds of glue tasks it’s so good at, and move to something like golang, because there’s not a great interface between the user and the script for configuring options at runtime. Parsing arguments can be downright unfriendly to the user, in fact, let alone to the developer. It doesn’t have to be this way! There’s no reason why Java and Python and Ruby and Golang and literally every other language out there can have high quality argument parsing libraries but Bash can’t have them.

    So I wrote cmdarg: A pure bash argument parsing library. This library solves all of the above problems you will suffer through in all of the above scenarios. Any time I need to add arguments to a bash script, I reach for this library, and I am always pleased with the result.

    Declarative Syntax for Clear Interfaces

    Cmdarg wants to help you build a clear interface to your script without asking you to write any of the parsing code. You want to write your script - you don’t want to write argument parsing code. So cmdarg allows you to declare the interface, parse the arguments, and get on with using the values in your script. Cmdarg assumes your script will take 0 or more command line arguments, and each one of these arguments will have: