4 ms·
If the command line arguments are getting to0 much, the next step is to use an config file, like an INI file and parse that. Very simple and removes all the ex
by louwrentius 6y ago
If the command line arguments are getting to0 much, the next step is to use an config file, like an INI file and parse that.
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.
- chriswarbo 6y agoConfig 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.