fix: preserve background operator in allowlist segments

Maintainer edit: keep a top-level trailing '&' in the segment being matched so background execution cannot be checked as if the ampersand were absent. Redirection forms like 2>&1 and &> remain untouched.
This commit is contained in:
chengyongru
2026-07-21 13:50:24 +08:00
committed by Xubin Ren
parent ab6ceef1a1
commit d5658dbc91
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -882,6 +882,7 @@ class ExecTool(Tool):
elif ch == "&" and not (
(i > 0 and command[i - 1] in "<>") or command.startswith("&>", i)
):
current.append(ch)
operator_len = 1
elif ch in {";", "|"}:
operator_len = 1