aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/mod.rs
diff options
context:
space:
mode:
authorJonas Maier <jonas@x77.dev>2026-05-04 23:57:57 +0200
committerJonas Maier <jonas@x77.dev>2026-05-04 23:57:57 +0200
commitbe3faf0552d60c996aeb51016f93ef64a3dd2d6f (patch)
tree0d770892864f1c66594494bee7f393663ad3441a /src/parse/mod.rs
parente56e2d1f9206102068c402a0cadbe62284816586 (diff)
downloadpish-be3faf0552d60c996aeb51016f93ef64a3dd2d6f.tar.gz
escape test
Diffstat (limited to 'src/parse/mod.rs')
-rw-r--r--src/parse/mod.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 02012dc..efef937 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -717,12 +717,12 @@ impl StringDelimiter {
let first = s[0];
match self {
StringDelimiter::None => {
- if matches!(first, b' ' | b'$' | b'\\' | b'\'' | b'"') {
+ if matches!(first, b' ' | b'$' | b'\\' | b'\'' | b'"' | b'|' | b'{' | b'}') {
out.push(b'\\');
}
}
StringDelimiter::Interp | StringDelimiter::InterpCustom(_) => {
- if matches!(first, b'$' | b'\\' | b'"') {
+ if matches!(first, b'$' | b'\\' | b'"' | b'|') {
out.push(b'\\');
}
}
@@ -750,6 +750,22 @@ impl StringDelimiter {
}
}
+ pub fn write_opening_delimiter(&self, out: &mut BString) {
+ match self {
+ StringDelimiter::None => (),
+ StringDelimiter::Interp => out.push(b'"'),
+ StringDelimiter::Strict => out.push(b'\''),
+ StringDelimiter::InterpCustom(delim) => {
+ out.push_all(&delim);
+ out.push_all(b"\"\"\"");
+ }
+ StringDelimiter::StrictCustom(delim) => {
+ out.push_all(&delim);
+ out.push_all(b"'''");
+ }
+ }
+ }
+
pub fn write_closing_delimiter(&self, out: &mut BString) {
match self {
StringDelimiter::None => (),
@@ -841,7 +857,7 @@ impl Parse for ExpString {
let x = b.adv();
- if x == b'\\' {
+ if x == b'\\' && !delim.is_strict() {
if let Some(x) = parse_escape_code(b)? {
add_char(p, x);
}