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

Commit62734c3

Browse files
committed
fix: Force bash for non-standard flags to exec
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 parentb8067c0 commit62734c3

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
@@ -82,15 +82,20 @@ coder sh front-end-dev cat ~/config.json`,
8282

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

96101
envName:=cmdArgs[0]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp