Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Respect Shebang #152

Closed
Bengt opened this issue Jun 25, 2014 · 4 comments
Closed

Feature Request: Respect Shebang #152

Bengt opened this issue Jun 25, 2014 · 4 comments

Comments

@Bengt
Copy link

Bengt commented Jun 25, 2014

atom-script always starts my Python scripts with the default python, even if i declare a shebang.

#!/usr/bin/env python3
import sys
print(sys.version_info)

and

#!/bin/python3
import sys
print(sys.version_info)

yield

sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)

Notice that it is common for python scripts to be only compatible with one major version, so a (global) configuration would not solve the issue.

@erran
Copy link
Collaborator

erran commented Jun 25, 2014

I'll take a look at this. I know #5 references virtualenv at one point. I use rbenv myself for Ruby and run from the command line which means I never see the conflicting paths though. Python is an interesting use case (the name of the executable that is).

erran added a commit to erran/atom-script that referenced this issue Jun 26, 2014
@Bengt
Copy link
Author

Bengt commented Jun 26, 2014

Notice that "Blanks after ! are OK.", so these variants should work, too:

#! /usr/bin/env python
#! /bin/python

Additionally, command line flags might be given to the interpreter: Some interesting cases are these:

#!/bin/python --version
#!/bin/python --
#!/bin/python -
#!/bin/python -3
#!/bin/python -c
#!/bin/python -O
#!/bin/python -OO
#!/bin/python -Q new

Also there are multiline shebangs. To start python from a polyglot bash/python file:

#!/bin/bash
"exec" "python" "$0"

print "Hello World"

@rgbkrk
Copy link
Member

rgbkrk commented Jun 27, 2014

I vote the very last one just gets handled by the bash handler. Why would anyone use that one?

@Bengt
Copy link
Author

Bengt commented Jun 30, 2014

@rgbkrk polyglot files can exploit features of both programming languages. For example bash knows $0 to be the filename, while the embedded language might not. This example is the not really useful but demonstrates the how to do this in bash/python. Python has in fact access to the filename sys.args[0], but other scripting languages do not. Perhaps there is something bash has access to and Python does not, but I do not know about such a thing. In any case, I think executing the file as a bash script should work just fine without action from atom-script's side.

@ghost ghost mentioned this issue Jul 14, 2014
@erran erran changed the title Respect Shebang Feature Request: Respect Shebang Jul 17, 2014
@erran erran closed this as completed in 99e2194 Jul 21, 2014
erran added a commit that referenced this issue Jul 21, 2014
Close #152 - Add support for reading shebang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants