From 531fd0d3bfce7241b2063d6d458680efe64f83c4 Mon Sep 17 00:00:00 2001 From: Andrew Cowie Date: Sun, 28 Jun 2026 15:35:17 +1000 Subject: [PATCH 1/2] Restrict use of poll() to Unix systems --- Cargo.toml | 4 +++- src/runner/library.rs | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f180169..4f8cfbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ crossterm = "0.29" ignore = "0.4" lsp-server = "0.8.0" lsp-types = "0.97" -nix = { version = "0.31", features = ["poll"] } owo-colors = "4" regex = "1.11.1" serde = { version = "1.0.209", features = [ "derive" ] } @@ -24,6 +23,9 @@ tinytemplate = "1.2.1" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = [ "env-filter" ] } +[target.'cfg(unix)'.dependencies] +nix = { version = "0.31", features = ["poll"] } + [build-dependencies] [profile.release] diff --git a/src/runner/library.rs b/src/runner/library.rs index 707ba52..47c79b0 100644 --- a/src/runner/library.rs +++ b/src/runner/library.rs @@ -1,9 +1,14 @@ //! The function table for the evaluator. -use std::io::{self, Read}; +use std::io; +#[cfg(unix)] +use std::io::Read; +#[cfg(unix)] use std::os::fd::AsFd; +#[cfg(unix)] use std::process::{Command, Stdio}; +#[cfg(unix)] use nix::poll::{poll, PollFd, PollFlags, PollTimeout}; use super::context::{Context, Stream}; @@ -274,6 +279,7 @@ fn pairs(_context: &Context, args: &[Value]) -> Result { /// are decoded at the end, so a chunk split mid-UTF-8 is harmless; trailing /// newlines are trimmed (matching shell substitution). A non-zero exit is an /// error. +#[cfg(unix)] fn exec(context: &Context, args: &[Value]) -> Result { let script = match &args[0] { Value::Literali(script) => script, @@ -418,11 +424,20 @@ fn exec(context: &Context, args: &[Value]) -> Result { )) } +#[cfg(not(unix))] +fn exec(_context: &Context, _args: &[Value]) -> Result { + Err(RunnerError::ExecError(io::Error::new( + io::ErrorKind::Unsupported, + "exec() is not supported on this platform", + ))) +} + /// Tee a chunk to the user, recording it plain in `captured` and writing it /// through the Context. Only whole lines are written through; the trailing /// partial line waits in `pending` for its newline (or the stream's close), so /// a `Stream::Stderr` run never lands inside a `Stream::Stdout` line. A newline /// is always a UTF-8 boundary, so this never splits a character either. +#[cfg(unix)] fn tee( bytes: &[u8], pending: &mut Vec, From 16c54f5ceb24f6ba6dd9f3ec67c13821e8b5df33 Mon Sep 17 00:00:00 2001 From: Andrew Cowie Date: Tue, 30 Jun 2026 17:05:52 +1000 Subject: [PATCH 2/2] Note MIME type --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1cdb0c..6079c2f 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ as well as very detailed ones: Detailed examples can be found in the _examples/_ and _tests/_ directories. -Documents written in Technique have file extension _\*.tq_. +Documents written in Technique have file extension _\*.tq_. The MIME type is +`application/technique`.