hare

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

isatty.ha (383B)


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