Skip to content

Commit 0d26e2e

Browse files
committed
fix: detect unix target for stdbuf
1 parent b86defa commit 0d26e2e

4 files changed

Lines changed: 8 additions & 19 deletions

File tree

src/uu/stdbuf/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ fn main() {
3838

3939
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
4040
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
41+
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap();
4142

43+
if target_family != "unix" {
44+
return;
45+
}
4246
let dylib_ext = if target_vendor == "apple" {
4347
".dylib"
44-
} else if target_os == "windows" || target_os == "cygwin" {
48+
} else if target_os == "cygwin" {
4549
".dll"
4650
} else {
4751
".so"

src/uu/stdbuf/locales/en-US.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ stdbuf-value-mode = MODE
2323
stdbuf-error-line-buffering-stdin-meaningless = line buffering stdin is meaningless
2424
stdbuf-error-invalid-mode = invalid mode {$error}
2525
stdbuf-error-value-too-large = invalid mode '{$value}': Value too large for defined data type
26-
stdbuf-error-command-not-supported = Command not supported for this operating system!
2726
stdbuf-error-external-libstdbuf-not-found = External libstdbuf not found at configured path: {$path}
2827
stdbuf-error-permission-denied = failed to execute process: Permission denied
2928
stdbuf-error-no-such-file = failed to execute process: No such file or directory

src/uu/stdbuf/locales/fr-FR.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ stdbuf-value-mode = MODE
2323
stdbuf-error-line-buffering-stdin-meaningless = la mise en mémoire tampon par ligne de stdin n'a pas de sens
2424
stdbuf-error-invalid-mode = mode invalide {$error}
2525
stdbuf-error-value-too-large = mode invalide '{$value}' : Valeur trop grande pour le type de données défini
26-
stdbuf-error-command-not-supported = Commande non prise en charge pour ce système d'exploitation !
2726
stdbuf-error-external-libstdbuf-not-found = libstdbuf externe introuvable au chemin configuré : {$path}
2827
stdbuf-error-permission-denied = échec de l'exécution du processus : Permission refusée
2928
stdbuf-error-no-such-file = échec de l'exécution du processus : Aucun fichier ou répertoire de ce type

src/uu/stdbuf/src/stdbuf.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
// spell-checker:ignore (ToDO) tempdir dyld dylib optgrps libstdbuf
77

8+
#[cfg(not(unix))]
9+
compile_error!("stdbuf is not supported on the target");
10+
811
use clap::{Arg, ArgAction, ArgMatches, Command};
912
use std::ffi::OsString;
1013
#[cfg(unix)]
@@ -107,22 +110,6 @@ fn preload_strings() -> UResult<(&'static str, &'static str)> {
107110
Ok(("DYLD_LIBRARY_PATH", "dylib"))
108111
}
109112

110-
#[cfg(not(any(
111-
target_os = "linux",
112-
target_os = "android",
113-
target_os = "freebsd",
114-
target_os = "netbsd",
115-
target_os = "openbsd",
116-
target_os = "dragonfly",
117-
target_vendor = "apple"
118-
)))]
119-
fn preload_strings() -> UResult<(&'static str, &'static str)> {
120-
Err(USimpleError::new(
121-
1,
122-
translate!("stdbuf-error-command-not-supported"),
123-
))
124-
}
125-
126113
fn check_option(matches: &ArgMatches, name: &str) -> Result<BufferType, ProgramOptionsError> {
127114
match matches.get_one::<String>(name) {
128115
Some(value) => match value.as_str() {

0 commit comments

Comments
 (0)