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

Commitc301cf0

Browse files
committed
Execute exec commands in sh
Change-Id: Iddf070b385a92a95933b94f260a5d509a192de5c
1 parentc8cec8e commitc301cf0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

‎cmd/coder/shell.go

Lines changed: 8 additions & 10 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,19 +80,16 @@ 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-
varargs []string
87-
ifcommand!="" {
88-
args=fl.Args()[2:]
89-
}
90-
91-
// Bring user into shell if no command is specified.
92-
ifcommand=="" {
93-
command="sh"
94-
args= []string{"-c","exec $(getent passwd $(whoami) | awk -F: '{ print $7 }')"}
86+
command:="sh"
87+
args:= []string{"-c"}
88+
iflen(fl.Args())>1 {
89+
args=append(args,strings.Join(fl.Args()[1:]," "))
90+
}else {
91+
// Bring user into shell if no command is specified.
92+
args=append(args,"exec $(getent passwd $(whoami) | awk -F: '{ print $7 }')")
9593
}
9694

9795
err:=runCommand(ctx,envName,command,args)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp