Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit51fd2d3

Browse files
authored
fix: Force bash for non-standard flags to exec (#226)
This addresses a regression introduced by#224. POSIX sh does notdefine arguments to the exec built-in, resulting in an error whenusing 'exec -a' to set the process name (argv[0]).This change executes /bin/bash instead of sh, and also changesto use 'exec -l', which automatically handles the hyphen prefixrequired to trigger login shell behavior.This also explicitly runs /bin/sh, aligning the behavior of"coder sh" and the frontend Terminal application.
1 parentc30c076 commit51fd2d3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎internal/cmd/shell.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,20 @@ coder sh front-end-dev cat ~/config.json`,
8383

8484
funcshell(cmd*cobra.Command,cmdArgs []string)error {
8585
ctx:=cmd.Context()
86-
command:="sh"
87-
args:=[]string{"-c"}
86+
varcommandstring
87+
varargs []string
8888
iflen(cmdArgs)>1 {
89+
command="/bin/sh"
90+
args= []string{"-c"}
8991
args=append(args,strings.Join(cmdArgs[1:]," "))
9092
}else {
9193
// Bring user into shell if no command is specified.
9294
shell:="$(getent passwd $(id -u) | cut -d: -f 7)"
93-
name:="-$(basename "+shell+")"
94-
args=append(args,fmt.Sprintf("exec -a %q %q",name,shell))
95+
96+
// force bash for the '-l' flag to the exec built-in
97+
command="/bin/bash"
98+
args= []string{"-c"}
99+
args=append(args,fmt.Sprintf("exec -l %q",shell))
95100
}
96101

97102
envName:=cmdArgs[0]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp