Skip to content

Escape backticks in zsh completion descriptions - #76126

Closed
walker1211 wants to merge 1 commit into
openclaw:mainfrom
walker1211:fix/zsh-completion-escape-backticks
Closed

walker1211 wants to merge 1 commit into
openclaw:mainfrom
walker1211:fix/zsh-completion-escape-backticks

Conversation

@walker1211

Copy link
Copy Markdown
Contributor

Summary

  • Escape backticks in generated zsh option descriptions to avoid command substitution.
  • Apply the same escaping to generated zsh subcommand descriptions.
  • Add a regression test covering command examples wrapped in backticks.

Test plan

  • pnpm --dir ~/Projects/github.com/openclaw exec node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts src/cli/completion-cli.test.ts
  • pnpm --dir ~/Projects/github.com/openclaw exec node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts
  • git diff --check

🤖 Generated with Claude Code

Prevent generated zsh completion scripts from treating command examples in descriptions as
command substitutions.
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: #64490 is already the open canonical PR for the same zsh completion description-escaping bug, and this newer PR is a narrower partial duplicate that does not cover the existing dollar-expansion case.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Keep #64490 as the canonical fix path and fold in any useful subcommand backtick coverage from this PR before landing one changelog-backed, validated zsh escaping patch.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main can be inspected by generating or reading the zsh completion output: descriptions containing backticks or $OPENCLAW_STATE_DIR flow into double-quoted _arguments strings without complete escaping.

Is this the best way to solve the issue?

No. Escaping backticks is necessary, but this PR is not the best standalone fix because it leaves dollar parameter expansion open and duplicates the existing broader PR.

Security review:

Security review cleared: The diff is limited to TypeScript completion generation and a colocated test, with no workflow, dependency, lockfile, install script, permission, artifact-download, or secret-handling changes.

What I checked:

  • Current main still has the zsh escaping gap: generateZshArgs embeds option descriptions into double-quoted zsh _arguments specs after escaping backslashes, quotes, and brackets, but not backticks or dollar signs. (src/cli/completion-cli.ts:196, ad0d87d88180)
  • This PR is partial: The diff adds backtick escaping in the option and subcommand description paths, but does not escape $, so the existing $OPENCLAW_STATE_DIR description case remains uncovered. (src/cli/completion-cli.ts:198, 7218bfe983bd)
  • Canonical overlapping PR is open: CLI: escape zsh completion descriptions #64490 is open, targets the same zsh completion description escaping surface, and already broadens the option-description fix to both backticks and $OPENCLAW_STATE_DIR. (71218a76191a)
  • Dependency contract supports broader escaping: Zsh expansion docs describe grave-accent command substitution and parameter expansion, which is why generated double-quoted zsh code needs to protect both backticks and $.
  • Changelog still needs consolidation in the canonical fix: The active Unreleased Fixes section exists, but this PR does not touch CHANGELOG.md for the user-facing CLI completion fix. (CHANGELOG.md:14, ad0d87d88180)

Likely related people:

  • hydro13: Recent merged work changed the same generated zsh completion script and added zsh integration coverage for deferred compinit registration. (role: recent zsh completion maintainer; confidence: high; commits: 6be14ab388eb; files: src/cli/completion-cli.ts, src/cli/completion-cli.test.ts)
  • steipete: GitHub history shows repeated recent changes in the completion CLI surface, including completion cache/update behavior and adjacent CLI refactors. (role: recent CLI/completion maintainer; confidence: medium; commits: f427ddc220b5, 63e00b811e74, fb73c0034eff; files: src/cli/completion-cli.ts, src/cli/completion-cli.test.ts, docs/cli/completion.md)
  • yiShanXin: Merged completion-generator hardening work in the same files, including generated shell script coverage and completion generator behavior. (role: adjacent completion hardening owner; confidence: medium; commits: bbb0c3e5d7d9; files: src/cli/completion-cli.ts, src/cli/completion-cli.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against ad0d87d88180.

@clawsweeper clawsweeper Bot closed this May 2, 2026
@clawsweeper clawsweeper Bot mentioned this pull request May 12, 2026
3 tasks done
steipete added a commit that referenced this pull request Sep 1, 2026
Reuse the canonical description encoder for the double-quoted zsh
arguments specification while retaining its single-quote layer. Remove
the duplicate escaping path and cover built-in, root, and nested commands
through real zsh parsing.

Fixes #135089
Related: #76126, #64490

Co-authored-by: walker <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
Reuse the canonical description encoder for the double-quoted zsh
arguments specification while retaining its single-quote layer. Remove
the duplicate escaping path and cover built-in, root, and nested commands
through real zsh parsing.

Fixes openclaw#135089
Related: openclaw#76126, openclaw#64490

Co-authored-by: walker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant