0

I have a directory with a list of files containing environment variables; for example a file named REALM that has the contents "dev", a file named TZ that has the contents "UTC", etc.

I'd like to set these in the current process environment, for example as part of .bash_profile. A tool exists to do this - envdir - however that's normally used when starting a subprocess.

Is there a good way to do this? At the moment I'm checking whether they are set in the .bash_profile and calling exec envdir /path/to/env bash if they are not set, though that seems hacky and risks a recursive loop.

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

1 Answers1

1

Aha, just eval the results of running env.

eval "$(env -i envdir /etc/meter-environment.d env)"
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305