Skip to content

feat: add tclsh, wish, and expect shebang detection for Tcl syntax#3647

Open
mvanhorn wants to merge 4 commits intosharkdp:masterfrom
mvanhorn:osc/3513-tcl-shebang
Open

feat: add tclsh, wish, and expect shebang detection for Tcl syntax#3647
mvanhorn wants to merge 4 commits intosharkdp:masterfrom
mvanhorn:osc/3513-tcl-shebang

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Adds first_line_match to the Tcl sublime-syntax definition so bat automatically detects Tcl scripts by their shebang line (#!/usr/bin/tclsh, #!/usr/bin/wish, #!/usr/bin/expect).

Why this matters

bat recognizes .tcl files but not Tcl scripts that use shebangs without extensions. Expect scripts (#!/usr/bin/expect) and Wish scripts (#!/usr/bin/wish) are common in automation and GUI tooling but get no syntax highlighting from bat today.

Changes

  • assets/patches/Tcl.sublime-syntax.patch: Adds first_line_match: ^\#!.*\b(tclsh|wish|expect)\b to the bundled Tcl syntax definition. The regex matches tclsh, wish, and expect in any shebang path (/usr/bin/, /usr/local/bin/, env wrappers).
  • CHANGELOG.md: Added feature entry.

Testing

  • cargo fmt -- --check: pass
  • cargo clippy --locked --all-targets --all-features -- -D warnings: pass
  • cargo test --locked: pass
  • Patch dry-run verified: patch --strip=0 --dry-run < patches/Tcl.sublime-syntax.patch succeeds

Fixes #3513

This contribution was developed with AI assistance (Claude Code).

Add first_line_match to the Tcl syntax definition via a patch file,
enabling automatic Tcl highlighting for scripts with tclsh, wish,
or expect shebangs.

Fixes sharkdp#3513
Copy link
Copy Markdown
Collaborator

@keith-hall keith-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks. It would be great if we could include some files without extensions, containing those shebang lines, in our "syntax regression tests" to be sure it works as expected and prevent regressions in future. (In particular, it looks like syntect is being improved so we may be able to bump the sublimehq/Packages submodule soon and I want to be sure we keep these improvements working)

CHANGELOG.md Outdated

## Features

- Add shebang-based detection for Tcl (`tclsh`, `wish`) and Expect (`expect`) scripts, see #3647 (@mvanhorn)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think perhaps this changelog entry could be better suited to the Syntaxes section, what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to Syntaxes in 29c913f.

…tion

Add extensionless regression test files for tclsh, wish, and expect
shebangs so syntect bumps don't silently break first-line detection.
Move changelog entry from Features to Syntaxes per reviewer suggestion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Added regression test files (extensionless, with tclsh/wish/expect shebangs) and integration tests in 29c913f. This should catch any regressions from syntect bumps. Also moved the changelog entry to the Syntaxes section.

Generate highlighted test outputs for tclsh, wish, and expect
shebang detection files to prevent regressions.
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Added syntax regression tests for all three shebangs (tclsh, wish, expect) in 0828a97.

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.

support shebang line recognition for tclsh and expect

2 participants