You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To reproduce, execute the following script on macOS:
#!/usr/bin/env bash
mkdir test;cdtest
mkdir foo bar 2>/dev/null
cat <<END >.envrcexport CDPATH=foo:bar:bazEND
direnv allow .eval"$(direnv export bash)"# The following /bin/sh script could fail.
/bin/sh <<ENDecho bash "$BASH_VERSION"cd foocd ../barEND
This script fails with the following output:
direnv: loading .envrc
direnv: export +CDPATH
bash 3.2.57(1)-release
/bin/sh: line 2: cd: foo: No such file or directory
/bin/sh: line 3: cd: ../bar: No such file or directory
On macOS, /bin/sh is the bash version 3.2, incorrectly handling CDPATH environment variable, as described here: http://unix.stackexchange.com/a/112364 – cd command just fails as above.
The solution could be to prevent exporting CDPATH to subshells, as it's not of much use of it out of interactive shell.
But with direnv it's not possible to define a variable without exporting it.
I suggest handling CDPATH in a special way, allowing it to be exported from .envrc, but preventing it to be further exported to subshells. What I mean is that $(direnv export) should output just CDPATH=... without the export qualifier.
The text was updated successfully, but these errors were encountered:
To reproduce, execute the following script on macOS:
This script fails with the following output:
On macOS,
/bin/sh
is the bash version 3.2, incorrectly handling CDPATH environment variable, as described here: http://unix.stackexchange.com/a/112364 –cd
command just fails as above.The solution could be to prevent exporting
CDPATH
to subshells, as it's not of much use of it out of interactive shell.But with direnv it's not possible to define a variable without exporting it.
I suggest handling
CDPATH
in a special way, allowing it to be exported from.envrc
, but preventing it to be further exported to subshells. What I mean is that$(direnv export)
should output justCDPATH=...
without theexport
qualifier.The text was updated successfully, but these errors were encountered: