2014-01-08 03:57:49 +00:00
|
|
|
function isatty -d "Test if a file or file descriptor is a tty."
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
# Use `command test` because `builtin test` doesn't open the regular fd's.
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
switch "$argv"
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
case '-h*' '--h*'
|
|
|
|
__fish_print_help isatty
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
case ''
|
|
|
|
command test -c /dev/stdin
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
case '*'
|
|
|
|
if test -e "$argv" # The eval here is needed for symlinks. Unsure why.
|
|
|
|
command test -c "$argv"; and eval tty 0>"$argv" >/dev/null
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
else if test -e /dev/"$argv"
|
|
|
|
command test -c /dev/"$argv"; and tty 0>/dev/"$argv" >/dev/null
|
2010-09-18 02:18:26 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
else if test -e /dev/fd/"$argv"
|
|
|
|
command test -c /dev/fd/"$argv"; and tty 0>/dev/fd/"$argv" >/dev/null
|
2006-09-19 16:53:17 +00:00
|
|
|
|
2014-01-08 03:57:49 +00:00
|
|
|
else
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
2006-09-19 16:53:17 +00:00
|
|
|
end
|