rcm icon indicating copy to clipboard operation
rcm copied to clipboard

Allow user to specify the target directory

Open eddsalkield opened this issue 5 years ago • 6 comments

A new default target can be set using:

  • A target option in rcrc(5)
  • -T flag A per-dotfiles target can be set using a target manifest file.

Provides a solution to issue #246.

eddsalkield avatar Jan 14 '20 23:01 eddsalkield

A few things to discuss: expanding environment variables in the target manifest file is currently handled safely by envsubst, which adds a dependency on GNU gettext. I believe this is the right approach, since GNU utilities are very portable and standardised.

If this dependency is a problem, however, I'm sure we can make it work by passing the internals to exec instead. It's a bit hacky and unsafe, but would do the trick without any additional dependencies.

eddsalkield avatar Jan 15 '20 10:01 eddsalkield

OK this diff isn't so bad -- we might have a good compromise here. I'll have to review it more carefully, but in the meantime I want to pop in to say: thank you!

mike-burns avatar Aug 28 '20 18:08 mike-burns

Any progress on this PR? Really hope this can be merged soon.

uzxmx avatar May 20 '22 02:05 uzxmx

This PR would add alot of value for me.

Amir-Ahmad avatar Jun 20 '22 06:06 Amir-Ahmad

Cool implementation, thank you for this! Hope you're still around.

I believe this is the right approach, since GNU utilities are very portable and standardised.

Most of my computers don't have much GNU code on them, so I'd prefer to find something in POSIX that we can rely on. I don't see envsubst in the OpenBSD man pages, for example. (It can be installed as a package, but at that point I'd just have people install a Rust compiler or whatever and stop maintaining painful shell code.)


This adds a new metafile, target, which I don't love. Is the use case real -- do you actually have one dotfiles dir that targets HOME and another that targets XDG_CONFIG_DIR?

mike-burns avatar Dec 30 '22 16:12 mike-burns

Yep, still around, although admittedly not using rcm as much at the moment and I have not very much availability to tweak this patch.

Rethinking this through, I still think the patch is useful but I'm less convinced that the target meta-file is absolutely necessary. This is because the user can just maintain one rcm directory for each target. The behaviour of checking multiple directories and falling back to the default isn't really necessary either since the user could do something like ${XDG_CONFIG_HOME:-$HOME/.config}.

I agree that envsubst isn't really too necessary. The -T command line option doesn't need to expand the environment variable, since the user's shell can probably do that for them. So the only place this is required to expand the target in the rcrc config file.

To drop the dependency, somebody needs to hack together a POSIX-compliant implementation in pure sh. Note that it'll probably be less secure since it might depend on exec.

eddsalkield avatar Jan 04 '23 15:01 eddsalkield