ixc / ixc-django-docker

Scripts and config files that make it easier to run Django projects consistently with and without Docker.
5 stars 1 forks source link

Running bash with --norc and --noprofile in bash.sh creates more problems than it solves #15

Open Aramgutang opened 6 years ago

Aramgutang commented 6 years ago

The call to bash --norc --noprofile here is a bit of half-measure that gives us worst of both worlds: https://github.com/ixc/ixc-django-docker/blob/b1af518fc535f6cca782bf9bbf8786d50acc2ed7/ixc_django_docker/bin/bash.sh#L57

Even though .bashrc and .bash_profile aren't loaded, any environment variables that were already set by them using export will still persist, so it's not really doing much to prevent "clashing with our paths". Specifically, the PATH value is persisted.

In my case, when running locally, this keeps all my variables, but removes useful things like alias ll="ls -la" and bind 'set completion-map-case on'. Most importantly, I have a custom PROMPT_COMMAND set to a local function, and while the PROMPT_COMMAND variable persists, the local function it refers to doesn't, so I get annoying errors after any command I run.

The proper way of running in a clean environment is env -i. This discards everything previously set by export. However, it comes with caveats of its own. It can't be used in bash.sh, because it will discard all the variables set by the previous links in the script chain, so it needs to be run at the very start of the entrypoint. But even that will end up discarding environment variables set by Docker Cloud, most importantly TRANSCRYPT_PASSWORD.

So in conclusion, I'd like for this line to be removed, and am seeking arguments to the contrary here.

mrmachine commented 6 years ago

@Aramgutang I don't remember the conflict that prompted that change, but I'd love it if we could enter a subshell of the same type and config as go.sh is launched with.