Skip to content

Commit 4aa2bde

Browse files
committed
stdbuf: Fix cfg block for Cygwin
1 parent a47744e commit 4aa2bde

3 files changed

Lines changed: 12 additions & 31 deletions

File tree

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: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// file that was distributed with this source code.
55

66
// spell-checker:ignore (ToDO) tempdir dyld dylib optgrps libstdbuf
7+
#[cfg(not(unix))]
8+
compile_error!("stdbuf is not supported on the target");
79

810
use clap::{Arg, ArgAction, ArgMatches, Command};
911
use std::ffi::OsString;
@@ -31,14 +33,9 @@ mod options {
3133

3234
#[cfg(all(
3335
not(feature = "feat_external_libstdbuf"),
34-
any(
35-
target_os = "linux",
36-
target_os = "android",
37-
target_os = "freebsd",
38-
target_os = "netbsd",
39-
target_os = "openbsd",
40-
target_os = "dragonfly"
41-
)
36+
unix,
37+
not(target_vendor = "apple"),
38+
not(target_os = "cygwin")
4239
))]
4340
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.so"));
4441

@@ -82,14 +79,7 @@ enum ProgramOptionsError {
8279
ValueTooLarge(String),
8380
}
8481

85-
#[cfg(any(
86-
target_os = "linux",
87-
target_os = "android",
88-
target_os = "freebsd",
89-
target_os = "netbsd",
90-
target_os = "openbsd",
91-
target_os = "dragonfly"
92-
))]
82+
#[cfg(all(unix, not(target_vendor = "apple"), not(target_os = "cygwin")))]
9383
#[expect(
9484
clippy::unnecessary_wraps,
9585
reason = "fn sig must match on all platforms"
@@ -107,20 +97,13 @@ fn preload_strings() -> UResult<(&'static str, &'static str)> {
10797
Ok(("DYLD_LIBRARY_PATH", "dylib"))
10898
}
10999

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-
)))]
100+
#[cfg(target_os = "cygwin")]
101+
#[expect(
102+
clippy::unnecessary_wraps,
103+
reason = "fn sig must match on all platforms"
104+
)]
119105
fn preload_strings() -> UResult<(&'static str, &'static str)> {
120-
Err(USimpleError::new(
121-
1,
122-
translate!("stdbuf-error-command-not-supported"),
123-
))
106+
Ok(("LD_PRELOAD", "dll"))
124107
}
125108

126109
fn check_option(matches: &ArgMatches, name: &str) -> Result<BufferType, ProgramOptionsError> {

0 commit comments

Comments
 (0)