Skip to content

Commit 6665e2d

Browse files
authored
better shellopts for commands and login/interactive shells (#907)
1 parent 41a34ad commit 6665e2d

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

pkg/shellexec/shellexec.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ func StartRemoteShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts Comm
179179
} else {
180180
if cmdOpts.Login {
181181
shellOpts = append(shellOpts, "-l")
182-
}
183-
if cmdOpts.Interactive {
182+
} else if cmdOpts.Interactive {
184183
shellOpts = append(shellOpts, "-i")
185184
}
186185
// zdotdir setting moved to after session is created
@@ -189,12 +188,6 @@ func StartRemoteShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts Comm
189188
log.Printf("combined command is: %s", cmdCombined)
190189
} else {
191190
shellPath = cmdStr
192-
if cmdOpts.Login {
193-
shellOpts = append(shellOpts, "-l")
194-
}
195-
if cmdOpts.Interactive {
196-
shellOpts = append(shellOpts, "-i")
197-
}
198191
shellOpts = append(shellOpts, "-c", cmdStr)
199192
cmdCombined = fmt.Sprintf("%s %s", shellPath, strings.Join(shellOpts, " "))
200193
log.Printf("combined command is: %s", cmdCombined)
@@ -301,8 +294,7 @@ func StartShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOpt
301294
} else {
302295
if cmdOpts.Login {
303296
shellOpts = append(shellOpts, "-l")
304-
}
305-
if cmdOpts.Interactive {
297+
} else if cmdOpts.Interactive {
306298
shellOpts = append(shellOpts, "-i")
307299
}
308300
}
@@ -312,12 +304,6 @@ func StartShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOpt
312304
shellutil.UpdateCmdEnv(ecmd, map[string]string{"ZDOTDIR": shellutil.GetZshZDotDir()})
313305
}
314306
} else {
315-
if cmdOpts.Login {
316-
shellOpts = append(shellOpts, "-l")
317-
}
318-
if cmdOpts.Interactive {
319-
shellOpts = append(shellOpts, "-i")
320-
}
321307
shellOpts = append(shellOpts, "-c", cmdStr)
322308
ecmd = exec.Command(shellPath, shellOpts...)
323309
ecmd.Env = os.Environ()

0 commit comments

Comments
 (0)