Issue512433
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-02-03 17:36 by jretz, last changed 2022-04-10 16:04 by admin. This issue is now closed.
Messages (2) | |||
---|---|---|---|
msg9108 - (view) | Author: Jimmy Retzlaff (jretz) | Date: 2002-02-03 17:36 | |
On Python 2.2 under Windows XP: os.system('"notepad" "test.py"') does not work as expected. It appears that os.system attempts to run: notepad" "test.py A workaround is to use: os.system('""notepad" "test.py""') Both of the following work as expected: os.system('notepad "test.py"') os.system('"notepad" test.py') os.popen exhibits the same behaviour. In naive testing, the following hack seems to make things better: os_system = os.system os.system = lambda command: os_system('"%s"' % command) This may suggest a potential fix in the C code - or it may simply offend the sensibilities of those more knowledgeable than me. :) |
|||
msg9109 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-10 01:47 | |
Logged In: YES user_id=31435 Sorry, I'm closing as "Won't Fix". os.system() and os.popen () are barely usable on Windows, and it's going to remain that way until Python grows its own command shell. Before that, it's at the mercy of what the MS shells happen to do. In the case of XP's cmd.exe, you're a victim of documented (by MS) behavior: see the /C and /K options to cmd.exe: """ If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters: 1. If all of the following conditions are met, then quote characters on the command line are preserved: - no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the two quote characters - the string between the two quote characters is the name of an executable file. 2. Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character. """ You're a victim of clause #2 there. The MS shells aren't consistent about these rules, so there's nothing Python can do to try to out-guess them, short of heroic efforts. For example, if we took your suggestion, things that work fine today under Win98's command.com would suddenly break (W98 does *not* strip the new quotes you're adding, so "Bad command or file name" is the usual result). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:04:56 | admin | set | github: 36021 |
2002-02-03 17:36:16 | jretz | create |