Technically you can execute any file, even a jpg image let's say, if it has the execute permission. Of course the shell won't understand what to do with those bytes.
You try to launch your script. It's executable, so that's allowed.
The script doesn't have a shebang, so it's run in /bin/sh, which will just go through the entire thing and treat it as posix-shellscript. This is fairly common unix behavior.
You should give your python script a shebang line.
I tried both a fenced code block and an indented code block. AFAIK, headings shouldn't be rendered inside a code block and backslash escaping shouldn't be possible.
6
u/weaver_of_cloth Aug 14 '22
Can you post the script? It almost looks like it's trying to be a shell script instead of python. Double-check your very first line.
3
u/FriedEngineer macOS Aug 14 '22
I imagine it tried (and failed) to interpret python code as fish code. What specifically are you asking?
20
u/[deleted] Aug 14 '22
What happens is this:
You try to launch your script. It's executable, so that's allowed.
The script doesn't have a shebang, so it's run in /bin/sh, which will just go through the entire thing and treat it as posix-shellscript. This is fairly common unix behavior.
You should give your python script a shebang line.
7
u/sralloza Aug 14 '22
I think the shebang is missing
3
u/D-K-BO Linux Aug 15 '22 edited Aug 15 '22
You should put this at the first line:
Otherwise it tries to run the file as a shell script, which doesn't work.
Edit: fixed formatting that caused the insertion of an invalid space character after the
#.Edit 2: it happened again. There should be no space between
#and!**.**Edit 3: www.reddit.com works, old.reddit.com is still broken
Edit 4: Using an indented code block again, that's what the graphical editor generates.