Skip to content

Detect shell-script Python executables in ScriptMaker shebangs#264

Open
l46983284-cpu wants to merge 1 commit into
pypa:masterfrom
l46983284-cpu:fix/scriptmaker-shell-executable-144
Open

Detect shell-script Python executables in ScriptMaker shebangs#264
l46983284-cpu wants to merge 1 commit into
pypa:masterfrom
l46983284-cpu:fix/scriptmaker-shell-executable-144

Conversation

@l46983284-cpu

Copy link
Copy Markdown

Summary

Fixes #144.

ScriptMaker only treated shell-script Python executables specially on Jython. On ordinary POSIX, a Nix-style wrapper (a bash script that execs the real interpreter) could still be written into a simple #! shebang.

This change:

  • lifts _is_shell() onto ScriptMaker for all platforms
  • forces the existing safe multi-line shebang form when the configured executable starts with #!
  • adds a focused regression test with a fake Nix-like wrapper

Test plan

  • cd tests && PYTHONPATH=..:. python3 -m unittest test_scripts -v → OK (21 tests, 5 Windows skips)
  • New test_shell_script_executable_shebang passes
  • Pre-existing unrelated test_util failures reproduce on clean master (not introduced here)

Nix and similar installs may provide a shell-script wrapper as the
Python executable. ScriptMaker only applied that check on Jython, so
POSIX shebangs could point at a nested script interpreter.

Lift _is_shell() to ScriptMaker for all platforms and force the safe
multi-line shebang when the configured executable starts with #!.

Fixes pypa#144

Signed-off-by: Alex Chen <l46983284@gmail.com>
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.

In general, ScriptMaker does not validate the Python executable is a shell script or not.

1 participant