Re:Conventions for Command Line Options
by chriswarbo on Monday August 03, 2020 @06:10AM
(#24035950)
Config files introduce a whole slew of complexity: race conditions, a whole bunch of new error conditions (permission denied, parse errors, read-only filesystems, disk full, etc.); system- or user-wide config files are spooky action-at-a-distance, which can make problems hard to track down, makes commands non-deterministic and may impact reproducibility (e.g. on other people's machines).
If commands insist on taking options via a config file, my preferred way to call them is to generate the config in-place via process substitution, e.g.
someCommand -c <(printf 'foo\n\tbar="%s"\n\tbaz="%s"\n' "$BAR" "$BAZ")
Although this isn't always possible, e.g. if 'someCommand' tries seeking around the config file rather than just parsing it in one pass.
Very simple and removes all the extensive command line clutter, especially if many settings stay the same.
I think environment variables are not very user friendly and not that visible.