jezdez / envdir

A Python port of daemontools' envdir.
https://envdir.readthedocs.io/
MIT License
229 stars 28 forks source link

A small patch that adds envshellfile command - very similar to envdir but reads the environment variables from a shellscript #48

Closed tkrajca closed 8 years ago

tkrajca commented 8 years ago

Say you have a shell script vars.sh with:

export tomas=krajca export envdir=isnice

envshellfile vars.sh env would run env command with environment variables from vars.sh

Happy to do some polishing :)

ticosax commented 8 years ago

Hi @tkrajca Thank you for this contribution. However I'm inclined to consider this feature goes out of scope of what envdir is entitled to serve. We do not wish to go beyond what the reference implementation is providing. I hope you understand.

tkrajca commented 8 years ago

Hi @ticosax, thanks for your reply, I do understand, no worries, I will probably create a new project envshellfile and use envdir as a dependency. Cheers.

blueyed commented 8 years ago

@tkrajca Check out https://github.com/direnv/direnv and similar tools (e.g. https://github.com/Tarrasch/zsh-autoenv), which might be easier to get what you want.

You can use snippets like the following with zsh-autoenv:

  for i in $envdir/*~*.*(.); do
    eval "autostash ${i:t}='$(<$i)'"
  done

This autostashes (exports and reverts when moving away) a list of envdir style files.

Regarding your example at hand, you could just source vars.sh?!

( source vars.sh; env_command )

I am closing this pull request for now.

Thanks for providing it though, of course!