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

Commite72927f

Browse files
authored
fix: Avoid running shell twice in coder agent (#5061)
The users login shell would be executed as:/bin/bash -c '/bin/bash -l'This simplifies the command for login shells so that the executedcommand is:/bin/bash -l
1 parentc515085 commite72927f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

‎agent/agent.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,25 +561,26 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
561561
returnnil,xerrors.Errorf("metadata is the wrong type: %T",metadata)
562562
}
563563

564+
// OpenSSH executes all commands with the users current shell.
565+
// We replicate that behavior for IDE support.
566+
caller:="-c"
567+
ifruntime.GOOS=="windows" {
568+
caller="/c"
569+
}
570+
args:= []string{caller,rawCommand}
571+
564572
// gliderlabs/ssh returns a command slice of zero
565573
// when a shell is requested.
566-
command:=rawCommand
567-
iflen(command)==0 {
568-
command=shell
574+
iflen(rawCommand)==0 {
575+
args= []string{}
569576
ifruntime.GOOS!="windows" {
570577
// On Linux and macOS, we should start a login
571578
// shell to consume juicy environment variables!
572-
command+="-l"
579+
args=append(args,"-l")
573580
}
574581
}
575582

576-
// OpenSSH executes all commands with the users current shell.
577-
// We replicate that behavior for IDE support.
578-
caller:="-c"
579-
ifruntime.GOOS=="windows" {
580-
caller="/c"
581-
}
582-
cmd:=exec.CommandContext(ctx,shell,caller,command)
583+
cmd:=exec.CommandContext(ctx,shell,args...)
583584
cmd.Dir=metadata.Directory
584585
ifcmd.Dir=="" {
585586
// Default to $HOME if a directory is not set!

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp