Skip to content

Commit c282015

Browse files
authored
[easy] added env variable to distinguish pure shell (#2024)
## Summary `devbox shell` and `devbox shell --pure` have differences in inheriting the host shell's env variables. But there is no devbox-defined env variable for users and devbox itself to know if it is in a pure shell or regular shell. This PR sets a `DEVBOX_PURE_SHELL=1` env variable to help fix that issue. This will allow users to differentiate and customize their setup based on if they're in a pure shell or not. For example, not sourcing `.bashrc` if in a pure shell. ## How was it tested? - `devbox run build` - `devbox shell` then `env | grep "DEVBOX_PURE_SHELL"` - exit - `devbox shell --pure` then `env | grep "DEVBOX_PURE_SHELL"` - confirm the env variable is set for pure shell and not for regular shell.
1 parent 7034939 commit c282015

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

internal/devbox/devbox.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,8 @@ func (d *Devbox) parseEnvAndExcludeSpecialCases(currentEnv []string) (map[string
12751275

12761276
// handling special case for PATH
12771277
if d.pure {
1278+
// Setting a custom env variable to differentiate pure and regular shell
1279+
env["DEVBOX_PURE_SHELL"] = "1"
12781280
// Finding nix executables in path and passing it through
12791281
// As well as adding devbox itself to PATH
12801282
// Both are needed for devbox commands inside pure shell to work

0 commit comments

Comments
 (0)