Ivan Perez
Ivan Perez

Reputation: 610

Passing environment variables to myrepos (mr)

I'm using joey hess' myrepos tool to manage multiple repos.

At some point, I'd like to pass environment variables to actions and sections so that they get expanded. In particular, I'm passing things like $SYNCTL, which should point to the top level directory where repositores are mounted.

(Note that this has nothing to do with the top-level dir as refered to by myrepos: that's the top level dir above which everything should be ignored, which is different.)

Unfortunately, those variables are not being expanded.

For instance, if I export SYNCTL=/home/myuser and then define the repo:

[$SYNCTL/myrepo]

in .mrconfig

that is never actually found. $SYNCTL is expanded to nothing, which results in myrepos looking for /myrepo, which obviously does not exist, so myrepos just ignores that section.

I also tried to expand the variable inside the repo section, like so:

[myrepo]
status = echo $SYNCTL

but that does not print anything either. In this case, the repo is found, but a blank line is printed.

There are some variables that can be expanded (like HOME), but not all seem to work. I thought it had something to do with --force-env, but running mr --force-env status does not print anything either.

Is there any way to work around this problem? Should there be?

Upvotes: 1

Views: 303

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 152917

Make sure that you export the SYNCTL environment variable. For example, in bash-alikes, instead of

SYNCTL=$HOME/reponame

which only defines a shell-local variable, use

export SYNCTL=$HOME/reponame

to make an environment variable that will be inherited by spawned processes.

Upvotes: 2

Related Questions