Skip to content

Change semantics of shebang in language configuration - #458

Merged
pehrsoderman merged 1 commit into
Kattis:masterfrom
gkreitz:457_adjust_shebang_semantics
Aug 13, 2026
Merged

Change semantics of shebang in language configuration#458
pehrsoderman merged 1 commit into
Kattis:masterfrom
gkreitz:457_adjust_shebang_semantics

Conversation

@gkreitz

@gkreitz gkreitz commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Changes the semantics of shebang handling in language detection. When specifying a shebang, one must also specify a pattern (matching a subset or all files matched by files) in which one does shebang detection.

Shebang detection now only applies to language detection. Once a language has been selected, all files matching files in that language are included (shebang or not). In particular, this means that if a program has a foo.py with a python2-shebang and a main.py without a shebang, it will now be detected as python2, with two files, foo.py and main.py, where main.py is the mainfile. Earlier code would have detected this as python2_with_shebang, with a single file, foo.py (which would then also end up as the mainfile).

Note that our shebang detection is not perfect, and not quite in line with the wording of the spec (which I think requires a shebang in every .py file - Kattis/problem-package-format#591 ). In particular, if you have more .py files without a shebang than you do .py files with a python2-shebang, the language will be detected as python3 (both before and after this PR). Fixing that requires a larger rewrite, which I'm not sure is worth it (as incorrect language detection is extremely likely to be very noticable).

Fixes #457

@pehrsoderman
pehrsoderman merged commit f3379cd into Kattis:master Aug 13, 2026
7 checks passed
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.

Rewrite shebang handling

2 participants