Skip to content

Support encoding markers: skip python/ruby encoding if present in first two lines - #14

Merged
tgamblin merged 4 commits into
mainfrom
bugfix/allow-extra-line-for-utf-encoding
Sep 4, 2026
Merged

tgamblin merged 4 commits into
mainfrom
bugfix/allow-extra-line-for-utf-encoding

Conversation

@becker33

@becker33 becker33 commented Sep 4, 2026

Copy link
Copy Markdown
Member

Python and Ruby can take code written in alternate encodings, but the encoding description must be written in a comment in the first two lines of the file.

To support this, sbang needs to look past the encoding to the third line of the file to find the interpreter if an encoding is being used.

This PR implements:

  • Skip a line if it is a pep-263 compliant encoding
  • Tests for common encoding strings in python and ruby

@becker33
becker33 force-pushed the bugfix/allow-extra-line-for-utf-encoding branch from 934fcc0 to d38c148 Compare September 4, 2026 15:08
Signed-off-by: Gregory Becker <becker33@llnl.gov>
@becker33
becker33 force-pushed the bugfix/allow-extra-line-for-utf-encoding branch from d38c148 to c010fc5 Compare September 4, 2026 15:09
Signed-off-by: Gregory Becker <becker33@llnl.gov>
Comment thread sbang Outdated
Comment thread sbang Outdated
Comment thread test/shebangs/python_with_encoding_minimal.py
Signed-off-by: Gregory Becker <becker33@llnl.gov>
Signed-off-by: Gregory Becker <becker33@llnl.gov>
@becker33 becker33 changed the title skip python/ruby encoding line if present in first two lines Support encoding markers: skip python/ruby encoding if present in first two lines Sep 4, 2026
@tgamblin
tgamblin merged commit 02d68b0 into main Sep 4, 2026
3 checks passed
@tgamblin
tgamblin deleted the bugfix/allow-extra-line-for-utf-encoding branch September 4, 2026 22:08
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