From 3faa37f332c8b6c056be5956f8743a67e4ee0aa3 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 17 Nov 2026 14:36:13 +0000 Subject: [PATCH] nice: gate by target support --- src/uu/nice/Cargo.toml | 3 ++- src/uu/nice/src/nice.rs | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 627fc6996cd..2f65cdb58af 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -16,7 +16,7 @@ path = "src/nice.rs" test = false doctest = false -[dependencies] +[target.'cfg(any(unix, windows))'.dependencies] clap = { workspace = true } fluent = { workspace = true } uucore = { workspace = true } @@ -33,3 +33,4 @@ workspace = true [[bin]] name = "nice" path = "src/main.rs" +required-features = ["uucore/default"] diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index afbbdf8deff..a9ec4cfcfc7 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -5,6 +5,8 @@ // spell-checker:ignore (ToDO) getpriority setpriority nstr PRIO +#![cfg(any(unix, windows))] + use clap::{Arg, ArgAction, Command}; use std::ffi::OsString; use std::io::{ErrorKind, Write, stdout}; @@ -125,7 +127,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { return Ok(()); }; - #[cfg(any(unix, windows))] let adjustment = match matches.get_one::(options::ADJUSTMENT) { None => 10, Some(nstr) => match nstr.parse::() { @@ -141,7 +142,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }, }; - #[cfg(any(unix, windows))] let new_niceness = current_niceness.saturating_add(adjustment); // We can't use `show_warning` because that will panic if stderr // isn't writable. The GNU test suite checks specifically that the @@ -177,10 +177,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let Err(err) = command.creation_flags(priority_class).spawn() else { return Ok(()); }; - #[cfg(not(any(unix, windows)))] - let Err(err) = command.status() else { - return Ok(()); - }; show_error!("{}: {err}", cmd.quote());