Skip to content

Commit

Permalink
resolve annoying stdin issue
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Sep 29, 2022
1 parent 319f20f commit 2906cd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ func Process() {
}

// Check if we are accepting data from stdin
stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
StandardInput = true
if len(DirFilePaths) == 0 {
stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
StandardInput = true
}
}

// If nothing was supplied as an argument to run against assume run against everything in the
Expand Down
6 changes: 3 additions & 3 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ else
exit
fi

if echo "hello" | ./hashit main.go --hash md5 | grep -q -i 'b1946ac92492d2347c6235b4d2611184'; then
if echo "hello" | ./hashit --hash md5 | grep -q -i 'b1946ac92492d2347c6235b4d2611184'; then
echo -e "${GREEN}PASSED stdin md5 test"
else
echo -e "${RED}======================================================="
Expand All @@ -154,7 +154,7 @@ else
exit
fi

if echo "hello" | ./hashit main.go --hash sha1 | grep -q -i 'f572d396fae9206628714fb2ce00f72e94f2258f'; then
if echo "hello" | ./hashit --hash sha1 | grep -q -i 'f572d396fae9206628714fb2ce00f72e94f2258f'; then
echo -e "${GREEN}PASSED stdin sha1 test"
else
echo -e "${RED}======================================================="
Expand All @@ -163,7 +163,7 @@ else
exit
fi

if echo "hello" | ./hashit main.go --hash sha256 | grep -q -i '5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03'; then
if echo "hello" | ./hashit --hash sha256 | grep -q -i '5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03'; then
echo -e "${GREEN}PASSED stdin sha256 test"
else
echo -e "${RED}======================================================="
Expand Down

0 comments on commit 2906cd6

Please sign in to comment.