Skip to content

docs: leave trailing shell comments out of copied commands - #4091

Merged
max-sixty merged 2 commits into
mainfrom
copy
Sep 13, 2026
Merged

max-sixty merged 2 commits into
mainfrom
copy

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Copy buttons copied shell commands with their trailing # comments, e.g. wt hook pre-merge user: # Run all user hooks. In zsh without interactivecomments, which is the default, a pasted trailing comment isn't a comment: the command runs as wt hook pre-merge user: '#' Run all user hooks.

withoutTrailingShellComments in docs/src/plugins/worktrunk-terminal.mjs applies the shell's rule, that a # beginning an unquoted word starts a comment, to what shell copy buttons copy: each per-line button in multi-command console blocks, the command lines of single-command console blocks, and whole bash and sh blocks. A line that is only a comment stays, as docs/CLAUDE.md already specifies for console blocks. 56 of the site's 339 copy payloads change (47 per-line buttons and 9 bash blocks). TOML, PowerShell and other payloads are unchanged, and a quoted # survives.

Tests: unit tests for the scanner (quotes, escapes, $#, operators, quotes spanning lines) and for a single-command console block with a trailing comment, plus a built-site test that no bash or sh payload carries a trailing comment, which fails on the build before this change.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

https://claude.ai/code/session_013U96NY8qKtZhavBSwnfCYq

max-sixty and others added 2 commits September 13, 2026 10:39
Copy buttons copied shell commands with their trailing `#` comments. In
zsh without `interactivecomments`, the default, a pasted trailing comment
is passed to the command as arguments.

`withoutTrailingShellComments` applies the shell's rule, that a `#`
beginning an unquoted word starts a comment, to per-line copies, the
command lines of single-command console blocks, and whole `bash` and `sh`
blocks. A line that is only a comment stays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013U96NY8qKtZhavBSwnfCYq
@max-sixty
max-sixty merged commit 5dec423 into main Sep 13, 2026
40 checks passed
@max-sixty
max-sixty deleted the copy branch September 13, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants