Skip to content

Commit

Permalink
Prevent shell inception from happening (#2643)
Browse files Browse the repository at this point in the history
## Summary
Running `devbox shell` inside a devbox shell is strictly prohibited 😆 

## How was it tested?
`go build -o devbox cmd/devbox/main.go`
`devbox shell`
`devbox shell` again

## Is this change backwards-compatible?
Yes
  • Loading branch information
LucilleH authored Aug 26, 2022
1 parent 9f0decc commit e9c08b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion boxcli/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package boxcli

import (
"fmt"
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -29,7 +30,12 @@ func runShellCmd(cmd *cobra.Command, args []string) error {
return errors.WithStack(err)
}

inDevboxShell := os.Getenv("DEVBOX_SHELL_ENABLED")
if inDevboxShell != "" && inDevboxShell != "0" && inDevboxShell != "false" {
return errors.New("You are already in an active devbox shell.\nRun 'exit' before calling devbox shell again. Shell inception is not supported.")
}

fmt.Println("Installing nix packages. This may take a while...")
// TODO: If we're inside a devbox shell already, don't re-run.

return box.Shell()
}

0 comments on commit e9c08b4

Please sign in to comment.