Skip to content

Commit

Permalink
Also output stderr if --show-output is given
Browse files Browse the repository at this point in the history
  • Loading branch information
terminationshock committed Aug 4, 2023
1 parent 5d50265 commit ef4ec90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ func RunCommand(match string) (string, string) {
var buffer bytes.Buffer
if config.showProgramOutput {
cmd.Stdout = &buffer
cmd.Stderr = &buffer
} else {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
cmd.Stderr = os.Stderr

err = cmd.Run()

Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func PrintHelp() {
fmt.Println(" separated by a colon")
fmt.Println(" --dirname Match the name of an existing directory")
fmt.Println("\nOther keyword OPTIONS:")
fmt.Println("\n --show-output Show the output of COMMAND")
fmt.Println("\n --show-output Show the output (both stdout and stderr) of COMMAND")
fmt.Println(" --filter Hide lines without a match")
fmt.Println(" --help Display this help")
fmt.Println("\nExamples:")
Expand Down
6 changes: 4 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ function run() {
diff test/RESULT_$1 test/EXPECT_$1
;;
19)
echo -e "./src/main.go:content\nMakefile:42:content" | ./lisst --filename --show-output echo -n foo > test/RESULT_$1
echo -e "foo ./src/main.go" > test/EXPECT_$1
echo -e "#!/bin/bash\necho \"\$@\";echo -n \"\$@\" 1>&2" > test/SCRIPT_$1
chmod +x test/SCRIPT_$1
echo -e "./src/main.go:content\nMakefile:42:content" | ./lisst --filename --show-output test/SCRIPT_$1 > test/RESULT_$1
echo -e "./src/main.go\n./src/main.go" > test/EXPECT_$1
diff test/RESULT_$1 test/EXPECT_$1
;;
20)
Expand Down

0 comments on commit ef4ec90

Please sign in to comment.