Skip to content

Commit

Permalink
make: handle when /dev/stderr doesn't exist (direnv#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm authored Apr 6, 2019
1 parent 7073767 commit e05d32a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ test-go: | $(base)
cd "$(base)" && $(GO) test -v ./...

test-go-fmt:
[ $$($(GO) fmt | tee /dev/stderr | wc -l) = 0 ]
[ $$($(GO) fmt | go run script/both/main.go | wc -l) = 0 ]

test-shellcheck:
shellcheck stdlib.sh
Expand Down
25 changes: 25 additions & 0 deletions script/both/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// a little script that outputs stdin back to both stdout and stderr
package main

import (
"os"
"io"
)

func main() {
buf := make([]byte, 2048)


for {
size, err := os.Stdin.Read(buf)
if err != nil {
if err != io.EOF {
panic(err)
}
return
}

os.Stdout.Write(buf[0:size])
os.Stderr.Write(buf[0:size])
}
}

0 comments on commit e05d32a

Please sign in to comment.