Skip to content

Instantly share code, notes, and snippets.

@fentas
Created February 15, 2019 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fentas/1de1a4fbc6a6fa4b0d6b94e184a1d1ef to your computer and use it in GitHub Desktop.
Save fentas/1de1a4fbc6a6fa4b0d6b94e184a1d1ef to your computer and use it in GitHub Desktop.
checks how input is redirected into shell script
#!/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