[Github-comments] [geany/geany] Invalid SyntaxError Non-ASCII character for Python 3 (#1298)

Colomban Wendling notifications at xxxxx
Fri Nov 11 18:39:02 UTC 2016


You can use an execute command like
```shell
sh -c 'if [ -x "%f" ]; then exec "./%f"; else exec python "%f"; fi'
```
Or even safer, checking it has a shebang that looks good:
```shell
sh -c 'if test -x "%f" && head -n1 "%f" | grep -q "^#!.*python"; then exec "./%f"; else exec python "%f"; fi'
```
Or just trusting the shebang, if any:
```shell
sh -c 'exec $(head -n1 "%f" | grep -Po "(?<=^#!).*$" || echo python) "%f"'
```
---
Geany will probably not try to read the shebang by default, because a user could select another filetype and reasonably expect his choice to be followed.  We could possibly consider executing the file directly if it's executable, but it can also lead to unexpected results if that file is mistakenly marked as executable (like on some non-POSIX file systems).
For now, IMO the best solution is for you to either make your own Python filetype run Python3, or use a conditional run command like I mentioned above.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1298#issuecomment-260024924
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20161111/ddedae0c/attachment.html>


More information about the Github-comments mailing list