Created
July 26, 2012 07:59
-
-
Save proger/3180858 to your computer and use it in GitHub Desktop.
kinda portable way to do isatty() in a shell
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
% cat t.sh ~ | |
#!/bin/sh | |
test -c /dev/stdin && echo "char" | |
test -p /dev/stdin && echo "named pipe" | |
test -S /dev/stdin && echo "socket" | |
test ! -f /dev/stdin && echo "not regular" | |
test -f /dev/stdin && echo "regular" | |
% sh ./t.sh ~ | |
char | |
not regular | |
% echo hi | sh ./t.sh ~ | |
named pipe | |
not regular | |
% sh ./t.sh < /etc/passwd ~ | |
regular |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment