Shell interpolation does not work on Windows

Bug #1266433 reported by esquifit
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UltiSnips
Invalid
Undecided
Unassigned

Bug Description

Shell interpolation does not work on Windows. Example

snippet dir "Insert contents of current directory"
`dir`
endsnippet

On expanding this, the output of the 'dir' command is not inserted. Interpolation for VimL and Python is working fine though.

The problem seems to be

File: plugin/Ultisnips/text_objects/_shell_code.py,
Line: 26
        proc = subprocess.Popen(path, shell=True, stdout=subprocess.PIPE)

In effect, this does not return anything (Note that the temporary file is correctly created and the interpolated code is written into it).

For this to work it is necessary to make the file executable. Line 23
        os.chmod(path, stat.S_IRWXU)
has apparently no effect in Windows. Instead, the temporary file needs to be registered to an executable type by means of an appropriate extension. Changing line 19:
        handle, path = tempfile.mkstemp(text=True)
by
        handle, path = tempfile.mkstemp(text=True, suffix='.bat')
solves the problem in a cross-platform way, since the .bat extension has no relevance outside Windows.

Not sure if this is the most elegant/correct way.

Revision history for this message
SirVer (sirver) wrote :

Which version are you using? the current code already uses .bat for windows: https://github.com/SirVer/ultisnips/blob/master/plugin/UltiSnips/text_objects/_shell_code.py#L24

Changed in ultisnips:
status: New → Incomplete
Revision history for this message
esquifit (esquifit+lp) wrote :

Hm, I see. I (naively?) checked the version in the ChangeLog file, according to which my version 2.2 would be the latest. I need to retrieve the latest one. This can be closed. Sorry for the noise and thanks for the quick answer.

Revision history for this message
SirVer (sirver) wrote :

> naively

absolutely not, you were not at fault at all. I just did not release in a long time - most users track directly from github using something like vundle and therelike, so there is little pressure on me.

Changed in ultisnips:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.