Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Reaction to Don't Require People to Change "Source Code" to Configure Your Programs

One of the blogs I read, Chris's Wiki :: blog, had an recent post titled Chris's Wiki :: blog/programming/ConfigureNoSourceCodeChanges. I considered posting a comment but had too much to say.

So after you read that article, read mine.

I have been intrisically doing this for quite some time, in various ways! I've written an overly-complicated template shell script that would load a series of conffiles, such as ~/.config/appname.conf, /etc/appname/appname.conf, and so on.

Nowadays, I use a process that just dot-sources ~/.config/appname.conf and then continues to define variables if not yet defined. Yes, I hardcode ~/.config rather than parse the fd.o XDG Base Directory spec.

Even if I have a single-instance deployment of some custom script, I tend to use some process like this. I don't want new versions of the script to affect the local configuration. It also makes it easier if I ever want to duplicate this script elsewhere: I can have the same script, and just local configs that are different.

And then of course if you get to the point of dpkg or rpm packages, those package managers handle config files for you. I prefer the rpm style, where it drops in a new file, /etc/appname/appname.conf.rpmnew and leaves it to you to deal with it entirely. But dpkg isn't so terrible. I feel it's more complicated and I've had to write complicated snippets to handle the config stuff to just always keep my config file instead of the package maintainer's version.

Comments