2

Is it bad practice to have a dot file and an adjacent identically named file without dot?


Background: We already create a $HOME/.ourapp directory where we store various configuration files, log files, etc. but we are debating where to put files that the user would add, create, and modify, either from outside the app or from within it, using various tools. It would seem most natural have these in $HOME/ourapp but that might be bad practice or confusing.

2
  • Let the user be able to configure it. Commented Jan 15, 2024 at 21:58
  • @ThorbjørnRavnAndersen It is configurable, but we need a default. Commented Jan 15, 2024 at 22:46

1 Answer 1

7

Is it bad practice to have a dot file and an adjacent identically named file without dot?

No. The "semantics" of dotfiles are (and this is very conventional and not very consistent) that they store user configuration, so they'd go along fine with "user-visible" non-dot-directories.

We already create a $HOME/.ourapp directory where we store various configuration files, log files, etc

I'd recommend against that – that's not good practice, which would be having a folder $XDG_CONFIG_HOME/ourapp (typically or if unset, $XDG_CONFIG_HOME is $HOME/.config) for configuration, $XDG_RUNTIME_DIR/ourapp for temporary files, $XDG_STATE_HOME/ourapp/logs (if unset, $XDG_STATE_HOMEis $HOME/.local/state) for state that should persist reboots, but isn't essential, like logs.

See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

That way, you

  1. don't clutter your user's home directory, and
  2. when the user runs a backup, they can just backup the XDG config directory, and all applications get backed up at once.

but we are debating where to put files that the user would add, create, and modify, either from outside the app or from within it, using various tools.

Important discussion!

I'd recommend asking the executable xdg-user-dir DOCUMENTS (or VIDEOS, or one of the other choices documented in man xdg-user-dir), and use e.g. $(xdg-user-dir DOCUMENTS)/ourapp for user-modified data: That would make sure the files are put where the user intuitively looks for them.

It would seem logical to an English speaker to put all such file simply into $HOME/Documents, but on non-English user accounts, these directories are typically called differently ($HOME/Dokumente on German gnome, for example); judging by the non-ASCII character in your name, I'd guess you're just like me all too aware of how annoying not being able to localize software is.

7
  • 1
    Thanks for the detailed answer and all the advice. We have a couple of problems with following the XDG recommendations. Firstly, we've used $HOME/.ourapp since 2012, and secondly, we want to be consistent across OSs, even non-free ones, us supporting both AIX and macOS. Using $HOME/.local/share/ourapp doesn't seem very user friendly. Commented Jan 15, 2024 at 12:36
  • your users should really never fiddle around in a dot directory, should they? so, that's really the right place to put stuff. Regarding cross-platformness: It's pretty common that things that work on Windows and POSIX-alike systems simply replace $HOME with %appdata for config files and use the Windows API to find Document folders! Regarding 12 years of legacy: I know that feeling, but really, you can write a few lines of code that first look in the "new" XDG directory, then in the "old" ~/.ourapp. If you know users never downgrade, you can also auto-migrate old to new location. Commented Jan 15, 2024 at 12:44
  • Not sure what you're saying here. We use .ourapp for things the user shouldn't fiddle with, and now need a location for things the user should fiddle with. I don't understand XDG's opinion that user-fiddlable things go to $HOME/.local/share/ourapp since that's also inside a dot directory. Commented Jan 15, 2024 at 16:08
  • no, no user-fiddlable things should go into that. I didn't mean that! I said: You probably want to split what's in your ~/.ourapp into config, which goes into ~/.config/ourapp, logs, which go into ~/.local/state. This has nothing to do with the user-"interfacing" files that should end up as described in the whole second part of my answer! So, they would end up in places that look like (localized versions of, as standardized by your operating system) ~/Documents/ourapp Commented Jan 15, 2024 at 16:10
  • I may be a bit slow here. What is the XDG's recommended fallback location for user-"interfacing" files when there are no XDG settings? Commented Jan 15, 2024 at 18:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.