Add direnv_apply_dump function to stdlib #90

Merged
merged 4 commits into from Jan 8, 2014

Conversation

Projects
None yet
2 participants
@timbertson
Contributor

timbertson commented Dec 28, 2013

It works with the new direnv apply-dump command to
convert a dumped environment (typically from a different process)
into a series of export statements which are then evaluated
in the current process.

Fixes #85, obsoletes #89.

Unfortunately the simple direnv_dump | direnv_apply_dump idea doesn't work because of subshells, so you need to use pipe redirecion (or whatever the <(command) syntax is called). I didn't make direnv apply-env accept a shell name, because as far as I can tell it's only ever used from bash - but this could be added in the future.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jan 7, 2014

Member

Since the pipe doesn't work, maybe it would be less error-prone if the commands where passed as arguments to the stdlib function ?

direnv_load "some command that ends with direnv dump"
Member

zimbatm commented Jan 7, 2014

Since the pipe doesn't work, maybe it would be less error-prone if the commands where passed as arguments to the stdlib function ?

direnv_load "some command that ends with direnv dump"
@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson Jan 7, 2014

Contributor

OK, I've implemented it as a function which runs "$@" and loads the dump from that.
This will mean you can't use a pipeline in the command generating direnv dump, but you can still use functions etc, so that's probably not a big issue.

I've also added a commit changing the name to direnv_load if you prefer (I'm not sure if your comment was suggesting renaming it, so if you're still happy with direnv_apply_dump you can just ignore a234c3d).

Cheers,
Tim.

Contributor

timbertson commented Jan 7, 2014

OK, I've implemented it as a function which runs "$@" and loads the dump from that.
This will mean you can't use a pipeline in the command generating direnv dump, but you can still use functions etc, so that's probably not a big issue.

I've also added a commit changing the name to direnv_load if you prefer (I'm not sure if your comment was suggesting renaming it, so if you're still happy with direnv_apply_dump you can just ignore a234c3d).

Cheers,
Tim.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jan 8, 2014

Member

Cool, yeah I prefer the symmetry of dump/load. Have you found out why the unit tests are failing ? I'll have a further look tomorrow and hopefully merge it.

Member

zimbatm commented Jan 8, 2014

Cool, yeah I prefer the symmetry of dump/load. Have you found out why the unit tests are failing ? I'll have a further look tomorrow and hopefully merge it.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jan 8, 2014

Member

PS: I renamed "$DIRENV_PATH" to simply "$direnv" in master, I'll rebase and fix it tomorrow if you don't get around to it.

Member

zimbatm commented Jan 8, 2014

PS: I renamed "$DIRENV_PATH" to simply "$direnv" in master, I'll rebase and fix it tomorrow if you don't get around to it.

timbertson added some commits Dec 28, 2013

Add direnv_apply_dump function to stdlib
It works with the new `direnv apply-dump` command to
convert a dumped environment (typically from a different process)
into a series of `export` statements which are then evaluated
in the current process.

Fixes #85
@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson Jan 8, 2014

Contributor

Ahh, yeah the tests are just failing because of "DIRENV_PATH". I just rebased, they should pass now.

Contributor

timbertson commented Jan 8, 2014

Ahh, yeah the tests are just failing because of "DIRENV_PATH". I just rebased, they should pass now.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jan 8, 2014

Member

Sweet, thanks @gfxmonk . Merging in.

Member

zimbatm commented Jan 8, 2014

Sweet, thanks @gfxmonk . Merging in.

zimbatm added a commit that referenced this pull request Jan 8, 2014

Merge pull request #90 from gfxmonk/direnv_apply_dump
Add direnv_apply_dump function to stdlib. Thanks @gfxmonk !

@zimbatm zimbatm merged commit 91352d0 into direnv:master Jan 8, 2014

1 check passed

default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment