forked from anchore/syft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable ETUI for piped input (anchore#571)
* fixed piped input Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * allow pipedinput helper to raise an error Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * factor out verbosity check to function Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
- Loading branch information
Showing
4 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// IsPipedInput returns true if there is no input device, which means the user **may** be providing input via a pipe. | ||
func IsPipedInput() (bool, error) { | ||
fi, err := os.Stdin.Stat() | ||
if err != nil { | ||
return false, fmt.Errorf("unable to determine if there is piped input: %w", err) | ||
} | ||
|
||
return fi.Mode()&os.ModeCharDevice == 0, nil | ||
} |