From 4aa9658bba8ee525390b68fdd8b4ec90c79fcfb8 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:40:06 +0900 Subject: [PATCH] stdbuf: detect unsupported target at build time --- src/uu/stdbuf/locales/en-US.ftl | 1 - src/uu/stdbuf/locales/fr-FR.ftl | 1 - src/uu/stdbuf/src/stdbuf.rs | 18 ++---------------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/uu/stdbuf/locales/en-US.ftl b/src/uu/stdbuf/locales/en-US.ftl index f2f845a07b6..50269efc3ee 100644 --- a/src/uu/stdbuf/locales/en-US.ftl +++ b/src/uu/stdbuf/locales/en-US.ftl @@ -23,7 +23,6 @@ stdbuf-value-mode = MODE stdbuf-error-line-buffering-stdin-meaningless = line buffering stdin is meaningless stdbuf-error-invalid-mode = invalid mode {$error} stdbuf-error-value-too-large = invalid mode '{$value}': Value too large for defined data type -stdbuf-error-command-not-supported = Command not supported for this operating system! stdbuf-error-external-libstdbuf-not-found = External libstdbuf not found at configured path: {$path} stdbuf-error-permission-denied = failed to execute process: Permission denied stdbuf-error-no-such-file = failed to execute process: No such file or directory diff --git a/src/uu/stdbuf/locales/fr-FR.ftl b/src/uu/stdbuf/locales/fr-FR.ftl index 5016c6914f1..b371361aec2 100644 --- a/src/uu/stdbuf/locales/fr-FR.ftl +++ b/src/uu/stdbuf/locales/fr-FR.ftl @@ -23,7 +23,6 @@ stdbuf-value-mode = MODE stdbuf-error-line-buffering-stdin-meaningless = la mise en mémoire tampon par ligne de stdin n'a pas de sens stdbuf-error-invalid-mode = mode invalide {$error} stdbuf-error-value-too-large = mode invalide '{$value}' : Valeur trop grande pour le type de données défini -stdbuf-error-command-not-supported = Commande non prise en charge pour ce système d'exploitation ! stdbuf-error-external-libstdbuf-not-found = libstdbuf externe introuvable au chemin configuré : {$path} stdbuf-error-permission-denied = échec de l'exécution du processus : Permission refusée stdbuf-error-no-such-file = échec de l'exécution du processus : Aucun fichier ou répertoire de ce type diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 773b5ff9ccc..da0ba7eccee 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -4,6 +4,8 @@ // file that was distributed with this source code. // spell-checker:ignore (ToDO) tempdir dyld dylib optgrps libstdbuf +#[cfg(not(unix))] +compile_error!("stdbuf is not supported on the target"); use clap::{Arg, ArgAction, ArgMatches, Command}; use std::ffi::OsString; @@ -107,22 +109,6 @@ fn preload_strings() -> UResult<(&'static str, &'static str)> { Ok(("DYLD_LIBRARY_PATH", "dylib")) } -#[cfg(not(any( - target_os = "linux", - target_os = "android", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", - target_os = "dragonfly", - target_vendor = "apple" -)))] -fn preload_strings() -> UResult<(&'static str, &'static str)> { - Err(USimpleError::new( - 1, - translate!("stdbuf-error-command-not-supported"), - )) -} - fn check_option(matches: &ArgMatches, name: &str) -> Result { match matches.get_one::(name) { Some(value) => match value.as_str() {