summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 4b8f8b29..518f145f 100644
--- a/sysif.c
+++ b/sysif.c
@@ -2128,6 +2128,26 @@ static val realpath_wrap(val path)
}
#endif
+#if HAVE_ISATTY
+static val isatty_wrap(val spec)
+{
+ val fdval;
+ val self = lit("isatty");
+
+ if (streamp(spec))
+ fdval = stream_get_prop(spec, fd_k);
+ else
+ fdval = spec;
+
+ if (fdval) {
+ int fd = c_int(fdval, self);
+ return if2(fd && isatty(fd) > 0, t);
+ }
+
+ return nil;
+}
+#endif
+
void sysif_init(void)
{
prot1(&at_exit_list);
@@ -2684,4 +2704,8 @@ void sysif_init(void)
#if HAVE_REALPATH
reg_fun(intern(lit("realpath"), user_package), func_n1(realpath_wrap));
#endif
+
+#if HAVE_ISATTY
+ reg_fun(intern(lit("isatty"), user_package), func_n1(isatty_wrap));
+#endif
}