zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 78ea270cc63197e4af312463d4f0c5490285d6ba (tree)
parent cffbb32d31495c83addae7ed3882dc000fb327aa
Author: Takeshi Yoneda <takeshi@tetrate.io>
Date:   Sun, 11 Dec 2022 17:44:38 +0900

wasi: fixes os.isatty on type mismatch (#13813)


Diffstat:
Mlib/std/os.zig | 2+-
Mlib/std/os/test.zig | 8++++++++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/std/os.zig b/lib/std/os.zig @@ -3158,7 +3158,7 @@ pub fn isatty(handle: fd_t) bool { if (builtin.os.tag == .wasi) { var statbuf: fdstat_t = undefined; const err = system.fd_fdstat_get(handle, &statbuf); - if (err != 0) { + if (err != .SUCCESS) { // errno = err; return false; } diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig @@ -1065,3 +1065,11 @@ test "timerfd" { try os.timerfd_settime(tfd, 0, &sit, null); try expectEqual(try os.poll(&fds, 5), 0); } + +test "isatty" { + var tmp = tmpDir(.{}); + defer tmp.cleanup(); + + var file = try tmp.dir.createFile("foo", .{}); + try expectEqual(os.isatty(file.handle), false); +}