Testing if a file is connected to a terminal

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 16 19:38:31 PST 2015


Is there a canonical way to test in D whether stdout/stderr (or in general, 
a std.stdio.File) refers to a terminal or not? 

https://www.google.co.in/search?q=terminal&sitesearch=dlang.org/phobos turns 
out nothing.

I knew of C's (or rather POSIX's) isatty, and after some digging I found 
isatty defined under core.sys.posix.unistd, and I suppose I can just pass to 
it the output of std.stdio.File.getFP.

Is there any other way to do the desired test? Or is this the recommended 
way?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d-learn mailing list