aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/process/process.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 06:25:03 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 06:25:03 +0900
commit6dd09abb33d86e1aa737667f9e15a18ed41d52e1 (patch)
tree83f961fb8657c3b5c8440caecaf61a52fdc3a2de /crates/shirabe-external-packages/src/symfony/process/process.rs
parent880a5eaad9dcdfd31563385f11ba1f63d38cfd14 (diff)
downloadphp-shirabe-6dd09abb33d86e1aa737667f9e15a18ed41d52e1.tar.gz
php-shirabe-6dd09abb33d86e1aa737667f9e15a18ed41d52e1.tar.zst
php-shirabe-6dd09abb33d86e1aa737667f9e15a18ed41d52e1.zip
refactor(external-packages): test for Windows with cfg!(windows)
MAIN_SEPARATOR is the path separator; PHP's `'\\' === DIRECTORY_SEPARATOR` uses it as an OS test only because PHP has no dedicated one. cfg!(windows) says what the branch actually selects on, and leaves MAIN_SEPARATOR to the sites that really join or split paths. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/process/process.rs')
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/process.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs
index 64ed3a84..3fb3fab2 100644
--- a/crates/shirabe-external-packages/src/symfony/process/process.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/process.rs
@@ -245,7 +245,7 @@ impl Process {
this.set_input(input)?;
this.set_timeout(timeout)?;
- this.use_file_handles = std::path::MAIN_SEPARATOR == '\\';
+ this.use_file_handles = cfg!(windows);
Ok(this)
}
@@ -309,7 +309,7 @@ impl Process {
.collect::<Vec<_>>()
.join(" ");
- if std::path::MAIN_SEPARATOR != '\\' {
+ if !cfg!(windows) {
// exec is mandatory to deal with sending a signal to the process
cmd = format!("exec {}", cmd);
}
@@ -318,7 +318,7 @@ impl Process {
CommandLine::String(s) => self.replace_placeholders(s, &env)?,
};
- if std::path::MAIN_SEPARATOR == '\\' {
+ if cfg!(windows) {
commandline = self.prepare_windows_command_line(&commandline, &mut env)?;
} else if !self.use_file_handles && self.is_sigchild_enabled() {
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
@@ -414,9 +414,8 @@ impl Process {
loop {
self.check_timeout()?;
let running = self.is_running()
- && (std::path::MAIN_SEPARATOR == '\\'
- || self.process_pipes.as_ref().unwrap().are_open());
- self.read_pipes(running, std::path::MAIN_SEPARATOR != '\\' || !running);
+ && (cfg!(windows) || self.process_pipes.as_ref().unwrap().are_open());
+ self.read_pipes(running, !cfg!(windows) || !running);
if !running {
break;
}
@@ -641,7 +640,7 @@ impl Process {
/// Enables or disables the TTY mode.
pub fn set_tty(&mut self, tty: bool) -> anyhow::Result<&mut Self> {
- if std::path::MAIN_SEPARATOR == '\\' && tty {
+ if cfg!(windows) && tty {
return Err(RuntimeException::new(
"TTY mode is not supported on Windows platform.".to_string(),
)
@@ -740,7 +739,7 @@ impl Process {
/// Creates the descriptors needed by the proc_open.
fn get_descriptors(&mut self) -> Vec<Descriptor> {
// TODO(plugin): $this->input instanceof \Iterator -> rewind() is not modeled.
- if std::path::MAIN_SEPARATOR == '\\' {
+ if cfg!(windows) {
self.process_pipes = Some(Box::new(WindowsPipes::new(self.input.clone())));
} else {
self.process_pipes = Some(Box::new(UnixPipes::new(
@@ -813,10 +812,7 @@ impl Process {
}
}
- self.read_pipes(
- running && blocking,
- std::path::MAIN_SEPARATOR != '\\' || !running,
- );
+ self.read_pipes(running && blocking, !cfg!(windows) || !running);
if !self.fallback_status.is_empty() && self.is_sigchild_enabled() {
// processInformation = fallbackStatus + processInformation (fallback keys win)
@@ -996,7 +992,7 @@ impl Process {
Some(pid) => pid,
};
- if std::path::MAIN_SEPARATOR == '\\' {
+ if cfg!(windows) {
let mut output: Vec<String> = Vec::new();
let mut exit_code: i64 = 0;
shirabe_php_shim::exec(
@@ -1189,7 +1185,7 @@ impl Process {
None | Some("") => return "\"\"".to_string(),
Some(a) => a,
};
- if std::path::MAIN_SEPARATOR != '\\' {
+ if !cfg!(windows) {
return format!("'{}'", argument.replace('\'', "'\\''"));
}
let mut argument = argument.to_string();