mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
* 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>
17 lines
377 B
Go
17 lines
377 B
Go
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
|
|
}
|