Running shebangless Python scripts may hang as /bin/sh runs `import`
Author: krobelusCreated Sep 2, 2026Updated Sep 2, 2026
As mentioned in https://matrix.to/#/!fny2klHK6fAZn_zfrCzd22UQxWritgFAuTLtN-ZFn_I/$QU6fnHcMogIKEfof8M7aIiP3bKcIv8nnFNFKMony0yc?via=gitter.im&via=matrix.org&via=tchncs.de
when executing a Python script that doesn't start with a #!/bin/python line,
fish assumes #!/bin/sh. Some Python scripts start with import. The shell executes import, a tool shipped with imagemagick that reads from stdin before doing anything. This caused users to not notice the error immediately.
IIRC fish already disables this logic for *.fish files. Maybe we should do the same for *.py files.
Source: fish-shell/fish-shell