From 597dda5a4b1a774ec8185c5f09213c6df3ed195b Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 1 Feb 2015 18:15:10 +0800 Subject: [PATCH] isatty: use command test instead of redirections Adds a fork but can't use builtin test yet. Closes #1870. --- share/functions/isatty.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/functions/isatty.fish b/share/functions/isatty.fish index d4f2c43e3..df8199250 100644 --- a/share/functions/isatty.fish +++ b/share/functions/isatty.fish @@ -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