Created
February 15, 2019 16:24
-
-
Save fentas/1de1a4fbc6a6fa4b0d6b94e184a1d1ef to your computer and use it in GitHub Desktop.
checks how input is redirected into shell script
This file contains hidden or 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
#!/bin/sh | |
if file "$(readlink /proc/$$/fd/0)" | grep -q "character special"; then | |
echo "Standard input:" | |
elif readlink /proc/$$/fd/0 | grep -q "^pipe:"; then | |
echo "Pipe input:" | |
else | |
echo "File input:" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment