Skip to content

Commit

Permalink
Trim trailing newlines from command representations
Browse files Browse the repository at this point in the history
  • Loading branch information
lesiw committed Oct 12, 2024
1 parent f2ef176 commit 57e1507
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func run(cmd io.Reader) error {
fmt.Fprintln(Trace, cmd)
fmt.Fprintln(Trace, strings.TrimRight(fmt.Sprintf("%v", cmd), "\n"))
a, ok := cmd.(Attacher)
if !ok {
// If this command does not implement Attacher, stream it to stdout
Expand All @@ -32,7 +32,7 @@ func run(cmd io.Reader) error {
}

func get(cmd io.Reader) (Result, error) {
fmt.Fprintln(Trace, cmd)
fmt.Fprintln(Trace, strings.TrimRight(fmt.Sprintf("%v", cmd), "\n"))

var r Result
var wg errgroup.Group
Expand Down
6 changes: 3 additions & 3 deletions pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func pipeTrace(src io.Reader, mid []io.ReadWriter) {
fmt.Fprintf(Trace, " | ")
}
if str, ok := e.(fmt.Stringer); ok {
fmt.Fprint(Trace, str.String())
fmt.Fprint(Trace, strings.TrimRight(str.String(), "\n"))
} else {
fmt.Fprintf(Trace, "<%T>", e)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func MustPipe(src io.Reader, cmd ...io.ReadWriter) {
e = cmd[i]
}
if str, ok := e.(fmt.Stringer); ok {
b.WriteString(str.String())
b.WriteString(strings.TrimRight(str.String(), "\n"))
} else {
fmt.Fprintf(&b, "<%T>", e)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func MustGetPipe(src io.Reader, cmd ...io.ReadWriter) Result {
e = cmd[i]
}
if str, ok := e.(fmt.Stringer); ok {
b.WriteString(str.String())
b.WriteString(strings.TrimRight(str.String(), "\n"))
} else {
fmt.Fprintf(&b, "<%T>", e)
}
Expand Down

0 comments on commit 57e1507

Please sign in to comment.