Skip to content

Commit 6db2327

Browse files
committed
feedback: remove stray '\r' on Windows on interactive input
1 parent 8586cde commit 6db2327

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/cli/feedback/terminal.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func InputUserField(prompt string, secret bool) (string, error) {
6262
fmt.Fprintln(stdOut)
6363
} else {
6464
value, err = bufio.NewReader(os.Stdin).ReadBytes('\n')
65-
if l := len(value); l > 0 {
65+
if l := len(value); l > 0 { // Trim \n
66+
value = value[:l-1]
67+
}
68+
if l := len(value); l > 0 && value[l-1] == '\r' { // Trim \r (it happens on Windows)
6669
value = value[:l-1]
6770
}
6871
}

0 commit comments

Comments
 (0)