From e3b4b41247e1e32794c9f14149707333438782f7 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:24:42 +0900 Subject: [PATCH] tty: Build tty.wasm --- .github/workflows/wasi.yml | 2 +- Cargo.toml | 1 + src/uu/tty/src/tty.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasi.yml b/.github/workflows/wasi.yml index 549e85dd0..8c3721d6a 100644 --- a/.github/workflows/wasi.yml +++ b/.github/workflows/wasi.yml @@ -37,7 +37,7 @@ jobs: CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run: | # Get all utilities and exclude ones that don't compile for wasm32-wasip1 - EXCLUDE="dd|df|du|env|expr|mktemp|more|tac|test|tty" + EXCLUDE="dd|df|du|env|expr|mktemp|more|tac|test" UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ') cargo test --target wasm32-wasip1 --no-default-features $UTILS - name: Run integration tests via wasmtime diff --git a/Cargo.toml b/Cargo.toml index 6a3307648..c27921add 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -235,6 +235,7 @@ feat_wasm = [ "true", "truncate", "tsort", + "tty", "uname", "unexpand", "uniq", diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 33c84804c..78b8d55ee 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -49,7 +49,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { set_exit_code(1); writeln!(stdout, "{}", translate!("tty-not-a-tty")) }; - + #[cfg(target_os = "wasi")] + let write_result = if std::io::stdin().is_terminal() { + // maximize compatibility + writeln!(stdout, r"/dev/tty") + } else { + set_exit_code(1); + writeln!(stdout, "{}", translate!("tty-not-a-tty")) + }; #[cfg(target_os = "windows")] let write_result = if std::io::stdin().is_terminal() { writeln!(stdout, r"\\.\CON")