hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

isatty.ha (375B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use io;
      5 use rt;
      6 
      7 // Returns whether the given stream is connected to a terminal.
      8 export fn isatty(fd: io::file) bool = {
      9 	let wsz = rt::winsize { ... };
     10 	match (rt::ioctl(fd, rt::TIOCGWINSZ, &wsz: *opaque)) {
     11 	case let e: rt::errno =>
     12 		return false;
     13 	case let r: int =>
     14 		return r == 0;
     15 	};
     16 };