Skip to content

Commit 8744b3d

Browse files
committed
Do not use sdtin when directories are passed
The check to use stdin was incorrectly true when running with no tty and no files were passed as arguments, even though directories were passed with -d Fixes #184
1 parent 8d013ec commit 8744b3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ var RootCmd = &cobra.Command{
6565
}
6666
// We detect whether we have anything on stdin to process if we have no arguments
6767
// or if the argument is a -
68-
if (len(args) < 1 || args[0] == "-") && !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) {
68+
notty := (stat.Mode() & os.ModeCharDevice) == 0
69+
noFileOrDirArgs := (len(args) < 1 || args[0] == "-") && len(directories) < 1
70+
if noFileOrDirArgs && !windowsStdinIssue && notty {
6971
var buffer bytes.Buffer
7072
scanner := bufio.NewScanner(os.Stdin)
7173
for scanner.Scan() {

0 commit comments

Comments
 (0)