Skip to content

Commit 7a7190a

Browse files
committed
cosash: Ensure we always inject trailing newline into commands
The `HasPrivileges()` API would hang forever because it didn't have a trailing newline in the command emitted. This took me some time to figure out. Let's fix this by auto-injecting a trailing newline automatically to entirely avoid the problem.
1 parent 32062fd commit 7a7190a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/pkg/cosash/cosash.go

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ func (r *CosaSh) ProcessWithReply(buf string) (string, error) {
137137
if _, err := io.WriteString(r.input, buf); err != nil {
138138
return "", err
139139
}
140+
if !strings.HasSuffix(buf, "\n") {
141+
if _, err := io.WriteString(r.input, "\n"); err != nil {
142+
return "", err
143+
}
144+
}
140145

141146
select {
142147
case reply := <-r.replychan:

0 commit comments

Comments
 (0)