Skip to content

Commit 04eb2b9

Browse files
committed
Fix SHELL environment variable
Change-Id: Icc30a29c2b55220bffc854d9848e9c99395f8a5c
1 parent eb2c835 commit 04eb2b9

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
.idea
1+
/.idea/
2+
/.repo/
23
ci/bin
34
cmd/coder/coder

cmd/coder/shell.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"os"
77
"os/signal"
8+
"strings"
89
"time"
910

1011
"github.com/spf13/pflag"
@@ -79,22 +80,18 @@ func (cmd *shellCmd) Run(fl *pflag.FlagSet) {
7980
}
8081
var (
8182
envName = fl.Arg(0)
82-
command = fl.Arg(1)
8383
ctx = context.Background()
8484
)
8585

86-
var args []string
87-
if command != "" {
88-
args = fl.Args()[2:]
86+
args := []string{"-c"}
87+
if fl.Arg(1) == "" {
88+
// Bring user into shell if no command is specified.
89+
args = append(args, "export SHELL=$(getent passwd $(whoami) | awk -F: '{ print $7 }'); $SHELL")
90+
} else {
91+
args = append(args, strings.Join(fl.Args()[1:], " "))
8992
}
9093

91-
// Bring user into shell if no command is specified.
92-
if command == "" {
93-
command = "sh"
94-
args = []string{"-c", "exec $(getent passwd $(whoami) | awk -F: '{ print $7 }')"}
95-
}
96-
97-
err := runCommand(ctx, envName, command, args)
94+
err := runCommand(ctx, envName, "sh", args)
9895
if exitErr, ok := err.(wsep.ExitError); ok {
9996
os.Exit(exitErr.Code)
10097
}

0 commit comments

Comments
 (0)