diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-14 11:24:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-14 11:28:19 +0900 |
| commit | 716f44031a39c5e43fb441ecc470db76efc23dd4 (patch) | |
| tree | e6f4a31e4bf55a0a8efb06d9dd4844c567e7390f /crates/shirabe/src/event_dispatcher | |
| parent | ef9118c788c1cbb22ca7721b6a9e40c2bf2fe243 (diff) | |
| download | php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.gz php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.zst php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.zip | |
refactor(pcre): drop Result from Preg method return types
The Preg methods panic on PCRE failure (per the file header rationale),
so their anyhow::Result wrappers never carried an Err.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/event_dispatcher')
| -rw-r--r-- | crates/shirabe/src/event_dispatcher/event_dispatcher.rs | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 8d3ac4b..3c23967 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -291,8 +291,7 @@ impl EventDispatcher { let mut callable = callable; if let Callable::String(ref s) = callable { if str_contains(s, "@no_additional_args") { - let replaced = Preg::replace("{ ?@no_additional_args}", "", s) - .unwrap_or_else(|_| s.clone()); + let replaced = Preg::replace("{ ?@no_additional_args}", "", s); callable = Callable::String(replaced); additional_args = Vec::new(); } @@ -647,17 +646,14 @@ impl EventDispatcher { if Preg::is_match( &format!("{{\\b{}$}}", preg_quote(&callable_str, None)), local_exec, - ) - .unwrap_or(false) - { + ) { let caller = BinaryInstaller::determine_binary_caller(local_exec); exec = Preg::replace( &format!("{{^{}}}", preg_quote(&callable_str, None)), &format!("{} {}", caller, local_exec), &exec, - ) - .unwrap_or(exec); + ); break; } } @@ -683,14 +679,12 @@ impl EventDispatcher { "{^\\S+}", |m| str_replace("/", "\\", &m[0]), &path_and_args, - ) - .unwrap_or(path_and_args); + ); } // match somename (not in quote, and not a qualified path) and if it is not a valid path from CWD then try to find it // in $PATH. This allows support for `@php foo` where foo is a binary name found in PATH but not an actual relative path let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); if Preg::is_match3("{^[^\\'\"\\s/\\\\]+}", &path_and_args, Some(&mut m)) - .unwrap_or(false) { let m0 = m.get(&CaptureKey::ByIndex(0)).cloned().unwrap_or_default(); @@ -703,8 +697,7 @@ impl EventDispatcher { "{\\.(exe|bat|cmd|com)$}i", "", &path_to_exec, - ) - .unwrap_or(path_to_exec.clone()); + ); // prefer non-extension file if it exists when executing with PHP if file_exists(&exec_without_ext) { path_to_exec = exec_without_ext; @@ -731,8 +724,7 @@ impl EventDispatcher { "{^\\S+}", |m| str_replace("/", "\\", &m[0]), &exec, - ) - .unwrap_or(exec); + ); } } @@ -1088,9 +1080,7 @@ impl EventDispatcher { PATH_SEPARATOR ), &path_value, - ) - .unwrap_or(false) - { + ) { Platform::put_env( path_env, &format!("{}{}{}", bin_dir, PATH_SEPARATOR, path_value), |
