ioquatix / script-runner

This package will run various script files inside of Atom. It currently supports JavaScript, CoffeeScript, Ruby, and Python. You can add more.
http://atom.io/packages/script-runner
Other
62 stars 23 forks source link

Execution Fails when Python Script Location Contains Spaces #40

Closed bryanhiestand closed 8 years ago

bryanhiestand commented 9 years ago

When opening a python script, whether w/ atom from Terminal or opening file GUI, script-runner errors out. This does not occur in script or when running python directly from terminal:

Running: python /private/tmp/space between/entertainment_center.py (pgid 61667) python: can't open file '/private/tmp/space': [Errno 2] No such file or directory

ioquatix commented 9 years ago

Interesting... I don't believe we do any processing of the path and pass it directly to the process spawn.

ioquatix commented 9 years ago

It looks like the problem might be with Shellwords usage..?

https://github.com/ioquatix/script-runner/blob/072cd316d7beb46333e029e8e771fbe1cb0458f3/lib/script-runner-process.coffee#L44-L48

ioquatix commented 9 years ago

Is it possible to get rid of the script wrapper now? I think that there were some bug fixes and features added to the Node PTY implementation which makes it basically usable. We should check out if it's possible now.

ioquatix commented 9 years ago

@huba I guess the problem is with this line:

https://github.com/ioquatix/script-runner/blob/072cd316d7beb46333e029e8e771fbe1cb0458f3/lib/script-runner-process.coffee#L38

The problem is that the path is not escaped so it gets borked when Shellwords.split is called.

The simplest solution might be to call Shellwords.escape on editor.getPath() but a better solution might be to call Shellwords.split on cmd earlier and work with the array (which would be slightly cleaner and more efficient).

ioquatix commented 9 years ago

@huba the only other thing to consider is https://github.com/ioquatix/script-runner/blob/072cd316d7beb46333e029e8e771fbe1cb0458f3/lib/script-runner-process.coffee#L50 where we print out the command being executed. It would be nice if this was a command you could copy and paste into a terminal and have it work the same way..