fix(639): quoted text and heredoc bodies are not commands when an act is matched to a moment
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 2s
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 2s
A Bash command was split into segments on every `&&`, `||`, `;`, `|` and newline, including those inside quotes and the lines of a heredoc. A script written with `python3 - <<EOF` that mentioned curl reached env.reach, and a grep for "a && git push" reached work.deliver. The splitter now reads the line as the shell does: separators inside quotes are text, a heredoc's body is skipped through its end word (`<<-` strips leading tabs), and a backslash-newline continues the line. Command triggers use the same split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,30 @@ def test_a_command_prefix_needs_a_word_boundary_and_the_head_of_a_segment(comman
|
||||
assert "work.deliver" not in _reached("Bash", {"command": command})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("command", [
|
||||
# A heredoc's body is data fed to a program, whatever its lines say.
|
||||
"python3 - <<'EOF'\nimport os\n | curl -fsS http://x\nEOF",
|
||||
"cat > hook.sh <<EOF\ncurl http://x\nEOF\nchmod +x hook.sh",
|
||||
"cat <<-END\n\tcurl http://x\n\tEND",
|
||||
# Quoted text is an argument, separators inside it included.
|
||||
'grep -n "a && curl http://x" file',
|
||||
"echo 'step; curl http://x'",
|
||||
'git commit -m "fix: curl | wget"',
|
||||
])
|
||||
def test_quoted_text_and_heredoc_bodies_are_not_commands(command):
|
||||
assert "env.reach" not in _reached("Bash", {"command": command})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("command", [
|
||||
"cat > x.sh <<'EOF'\necho hi\nEOF\ncurl http://x",
|
||||
"python3 - <<EOF && curl http://x\nprint(1)\nEOF",
|
||||
'echo "a;b" ; curl http://x',
|
||||
"make build \\\n && curl http://x",
|
||||
])
|
||||
def test_a_command_after_a_heredoc_or_a_quote_is_still_one(command):
|
||||
assert "env.reach" in _reached("Bash", {"command": command})
|
||||
|
||||
|
||||
def test_one_action_reaches_every_moment_it_is():
|
||||
"""`kubectl apply` is a run, a deliver and a reach outside the workspace."""
|
||||
assert _reached("Bash", {"command": "kubectl apply -f deploy.yaml"}) == [
|
||||
|
||||
Reference in New Issue
Block a user