Diff
1diff --git a/src/core/deterministic.ts b/src/core/deterministic.ts
2index 2ff930c42c1c2f0822ffd9737d619e1e86175edc..e476c427090ede47d492a601676b6218377f4883 100644
3--- a/src/core/deterministic.ts
4+++ b/src/core/deterministic.ts
5@@ -129,9 +129,7 @@ function hasUnsafeWordSyntax(command: string, allowStaticGlobs = false): boolean
6 if (character === "'") {
7 quote = undefined;
8 if (quotedOptionValue) optionValueQuoteClosed = true;
9- continue;
10 }
11- if (character === "$" || character === "~") return true;
12 continue;
13 }
14
15@@ -484,7 +482,12 @@ function isSpecialAllowedCommand(program: string, arguments_: string[]): boolean
16 if (program === "command") return arguments_[0] === "-v";
17 if (program === "find") return isSafeFind(arguments_);
18 if (program === "sed") {
19- return arguments_[0] === "-n" && /^\d{1,7}(?:,\d{1,7})?p(?:;\d{1,7}(?:,\d{1,7})?p)*$/.test(arguments_[1] ?? "");
20+ const script = arguments_[1] ?? "";
21+ return (
22+ arguments_[0] === "-n" &&
23+ (/^\d{1,7}(?:,\d{1,7})?p(?:;\d{1,7}(?:,\d{1,7})?p)*$/.test(script) ||
24+ /^\/(?:[^/\\\r\n]|\\.)*\/,\/(?:[^/\\\r\n]|\\.)*\/p$/.test(script))
25+ );
26 }
27 if (program === "pacman") return ["-Q", "-Ql", "-Qo", "-Si"].includes(arguments_[0] ?? "");
28 if (program === "rpm") return arguments_[0] === "-qa";
29diff --git a/test/core/deterministic.test.ts b/test/core/deterministic.test.ts
30index 3fc24d649735d25ad5743d9957da1b4e1eec95e2..0c48cd2720c29b41843482a88bd1b3cf7caa50d2 100644
31--- a/test/core/deterministic.test.ts
32+++ b/test/core/deterministic.test.ts
33@@ -41,6 +41,7 @@ test("allows recognized deterministic command grammars", () => {
34 "cargo test",
35 "nl -ba src/core/rules.ts",
36 "sed -n '10,20p' src/core/rules.ts",
37+ "sed -n '/^llama/,/^$/p' Makefile",
38 "pacman -Ql bash",
39 "rpm -qa",
40 "dpkg-query -W bash",