Expected Config File Locations
Smylers at stripey.com
Tue Aug 30 13:55:48 BST 2011
Hi. I'm looking for some advice on where I should put the config file
for a command I'm distributing on Cpan. Where would you it to be? I'm
interested in opinions of Windows, Mac, and Unix users, for both
per-user and system-wide config.
Or has anybody here dealt with this in Perl, for a command which comes
with a Cpan module and could be installed on any OS where Perl runs?
File::ConfigDir looks like it should be useful for this. I think I'd
want the system_cfg_dir and user_cfg_dir functions (my command doesn't
have a graphical interface, so I don't think it counts as a 'desktop
application') -- do these seem plausible for your platform?
In particular, on Windows:
* system_cfg_dir returns the value of %windir%. Is %windir%\bang* a
sensible place for the config of a command called bang?
* user_cfg_dir returns the user's home directory. Is that a sensible
place for a configuration file?
I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user
config -- is that better?
* What name would you expect the file to have? Unix has the convention
of a leading dot, such as .vimrc, to hide the file and prevent it from
cluttering up typical directory listings. I see that Vim uses the name
_vimrc on Windows.
What about the file extensions? I see .psqlrc on Unix is psqlrc.conf
on Windows; does the .conf help with using a text editor to edit it?
* Most Windows systems seem to be single-user; do I even need both
system-wide and per-user locations on Windows, and if not which one
would you expect to find?
And on Unix:
* system_cfg_dir always returns /etc/. On some Unices such as FreeBSD
I've seen /usr/local/etc/ used for commands that are installed under
/usr/local/. Is that what you'd expect?
File::ConfigDir has local_cfg_dir, which returns /usr/local/etc. So I
could use that if the command has been installed in /usr/local/bin/
and stick with /etc/ otherwise.
But I'd be surprised to find /usr/local/etc/ being used on Linux.
* What filename would you expect for a command's configuration file? I'm
used to the "rc" suffix, so .bangrc for a command called bang, but for
many of the common .*rc files the contents are genuine 'run commands'.
For example, .bashrc, .muttrc, and .vimrc all contain commands which
could be typed into the program interactively after starting it.
That doesn't apply to my command, which isn't interactive, so maybe rc
isn't the best suffix. But there are others like this, such as
.screenrc, .cvsrc, .lynxrc, .offlineimaprc, and .muttprintrc.
Git has .gitconfig and SSH .ssh/config. MySQL uses .my.cnf. Would
.bangconfig or .bang.cnf be better than .bangrc?
And on OSX:
* Is this aspect of the system sufficiently similar to FreeBSD that
whatever is appropriate there would be appropriate on OSX as well? If
not, what's different?
Thanks for any wisdom you can share.
Watch fiendish TV quiz 'Only Connect' (some questions by me)
Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect
More information about the london.pm