Skip to content

Commit

Permalink
Do not use sdtin when directories are passed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
carlossg committed Dec 17, 2019
1 parent 8d013ec commit 8744b3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ var RootCmd = &cobra.Command{
}
// We detect whether we have anything on stdin to process if we have no arguments
// or if the argument is a -
if (len(args) < 1 || args[0] == "-") && !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) {
notty := (stat.Mode() & os.ModeCharDevice) == 0
noFileOrDirArgs := (len(args) < 1 || args[0] == "-") && len(directories) < 1
if noFileOrDirArgs && !windowsStdinIssue && notty {
var buffer bytes.Buffer
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
Expand Down

0 comments on commit 8744b3d

Please sign in to comment.