Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/manage/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _replace_templates(cmd, line, windowed):
if not m:
return None, None

template_key = None
full_key = (m.group(1) + m.group(2)).strip()
if full_key in cmd.shebang_templates:
template_key = full_key
Expand All @@ -137,6 +138,15 @@ def _replace_templates(cmd, line, windowed):
template_key = m.group(1)
suffix = m.group(2)
else:
# Also map case-insensitive keys back to their original casing
keys_cf = {k.casefold(): k for k in cmd.shebang_templates}
template_key = keys_cf.get(full_key.casefold())
suffix = ""
if not template_key:
template_key = keys_cf.get(m.group(1).casefold())
suffix = m.group(2)

if not template_key:
return None, None

new_cmd = cmd.shebang_templates[template_key]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ def test_quote_args(args, expect):
("#! /usr/bin/python3", "PythonCore3", None),
("#! /usr/bin/pythonw3", "PythonCore3", None),
("#! custom", None, "#!CUSTOM"),
("#! CUSTOM", None, "#!CUSTOM"),
("#! full line custom", None, "#!CUSTOM2"),
("#! FULL LINE CUSTOM", None, "#!CUSTOM2"),
("#!full line custom with extra", None, None),
("custom", None, None),
("full line custom", None, None),
Expand Down
Loading