kitware-resonant / cookiecutter-resonant

Apache License 2.0
11 stars 6 forks source link

export-env.sh supports custom .env file #150

Open danlamanna opened 3 years ago

danlamanna commented 3 years ago

What's the rationale for this line? Wouldn't this part of the if statement be equivalent to just . somefile?

https://github.com/girder/cookiecutter-girder-4/blob/850c51ece29bd03683fd0ef3fe1feabb1b384151/%7B%7B%20cookiecutter.project_slug%20%7D%7D/dev/export-env.sh#L7

Running . export-env.sh works on zsh and bash, but if I put it into my .envrc it passes my .envrc file as $1 - which results in an endless loop. Removing the if statement and unconditionally executing the else block seems to work in both scenarios.

Where is export-env.sh being called with an argument?

brianhelba commented 3 years ago

The intent was to provide the ability to pass other .env files, as a general utility to users. Hopefully, this makes export_env.sh significantly more useful than if the .env file is hardcoded.

In the basic cookiecutter, there are no such other .files, but I was envisioning that some downstreams might add them.

However, if this feature is present, it definitely needs to work in any context which the script is sourced.

@danlamanna Do you know an alternate way to "get the first argument after the script file" which is more robust?

brianhelba commented 1 month ago

@danlamanna Any thoughts?