Path component movement to skip all escaped characters

Extend the hack added in ebc140a3ea (Hack path component movement to
skip escaped spaces, 2025-12-16) to apply to all characters, such as
";" that may be part of a file name.
This commit is contained in:
Johannes Altmanninger
2026-05-16 21:31:36 +08:00
parent ec52a999b3
commit 1284527fac

View File

@@ -243,7 +243,7 @@ fn path_component_state_transition(
use PathComponentTransition as T;
ControlFlow::Continue(if is_blank(c) && !escaped {
T::Blank
} else if is_path_component_character(c) || (is_blank(c) && escaped) {
} else if escaped || is_path_component_character(c) {
T::PathComponent
} else {
T::Punctuation
@@ -438,7 +438,7 @@ macro_rules! validate {
}
assert!(
stops.is_empty(),
"expected to stop at {stops:?} but not. String: {command:?}"
"expected to stop at {stops:?} but did not. String: {command:?}"
);
}
}
@@ -459,7 +459,8 @@ macro_rules! validate {
validate!(Left, PathComponents, "^aa^@@ ^aa@@^a^");
validate!(Left, PathComponents, r#"^a\ ^b\ c/^d"^e\ f"^g"#);
validate!(Left, PathComponents, r#"^a\ ^b\ c/^d"^e\\\ f"^g"#);
validate!(Left, PathComponents, r#"^a\"^bc^"#);
validate!(Left, PathComponents, r#"^a\;b^"#);
validate!(Left, PathComponents, r#"^a\"bc^"#);
validate!(Right, PathComponents, "^/^foo/^bar/^baz/^");
validate!(Right, PathComponents, "^echo ^--foo ^--bar^");