clausreinke / typescript-tools

(repo no longer active) Tools related to the TypeScript language
Apache License 2.0
266 stars 29 forks source link

subprocess.Popen in the vim plugin should be given a quoted string, not a list #18

Closed tomjakubowski closed 11 years ago

tomjakubowski commented 11 years ago

from the docs:

On Unix with shell=True, the shell defaults to /bin/sh. If args is a string, the string specifies the command to execute through the shell. This means that the string must be formatted exactly as it would be when typed at the shell prompt. This includes, for example, quoting or backslash escaping filenames with spaces in them. If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell itself. That is to say, Popen does the equivalent of: Popen(['/bin/sh', '-c', args[0], args[1], ...])

this line caused :TSSstarthere to fail with a vexing error like "TSS not started" for me (Python 2.7.2, Mac OS X 10.8). I added some debugging output and found that, every time :TSSstart was called, process.argv in the tss.js script was set to [ 'node', '/usr/local/bin/tss' ] because the additional arguments given to Popen were passed to the shell and not to the tss process.

clausreinke commented 11 years ago

Sigh. Trust python to make cross-platform coding difficult.

Thanks for the report - I can only test on windows, and I would like to avoid getting into the different quoting conventions, or having platform-specific configurations.

Can the globally installed tss be run without the intermediate shell (setting shell=False), keeping everything else unchanged?

tomjakubowski commented 11 years ago

Running the globally installed tss with shell=False works fine on Mac OS X, so no need to deal with cross-platform quoting headaches. Maybe the shell option there could be determined by OS or configurable by the user.

clausreinke commented 11 years ago

I am slightly surprised that noone else has been running into this on unixy systems. Please let me know if there is anything else not working as described.