isatty: use command test instead of redirections

Adds a fork but can't use builtin test yet.

Closes #1870.
This commit is contained in:
David Adam 2015-02-01 18:15:10 +08:00
parent 66acd17bc0
commit 597dda5a4b

View file

@ -8,7 +8,7 @@ function isatty -d "Tests if a file descriptor is a tty"
__fish_print_help isatty
return 0
case stdin
case stdin ''
set fd 0
case stdout
@ -23,6 +23,8 @@ function isatty -d "Tests if a file descriptor is a tty"
end
end
eval "tty 0>&$fd >/dev/null"
# Use `command test` because `builtin test` doesn't open the regular fd's.
# See https://github.com/fish-shell/fish-shell/issues/1228
command test -t "$fd"
end