Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the subprocess.py source:</p> <blockquote> <p>On UNIX, with shell=True: If args is a string, it specifies the command string to execute through the shell. If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional shell arguments.</p> <p>On Windows: the Popen class uses CreateProcess() to execute the child program, which operates on strings. If args is a sequence, it will be converted to a string using the list2cmdline method. Please note that not all MS Windows applications interpret the command line the same way: The list2cmdline is designed for applications using the same rules as the MS C runtime.</p> </blockquote> <p>That doesn't answer why, just clarifies that you are seeing the expected behavior.</p> <p>The "why" is probably that on UNIX-like systems, command arguments are actually passed through to applications (using the <code>exec*</code> family of calls) as an array of strings. In other words, the calling process decides what goes into EACH command line argument. Whereas when you tell it to use a shell, the calling process actually only gets the chance to pass a single command line argument to the shell to execute: The entire command line that you want executed, executable name and arguments, as a single string.</p> <p>But on Windows, the entire command line (according to the above documentation) is passed as a single string to the child process. If you look at the <a href="http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx" rel="nofollow noreferrer">CreateProcess</a> API documentation, you will notice that it expects all of the command line arguments to be concatenated together into a big string (hence the call to <code>list2cmdline</code>).</p> <p>Plus there is the fact that on UNIX-like systems there actually <em>is</em> a shell that can do useful things, so I suspect that the other reason for the difference is that on Windows, <code>shell=True</code> does nothing, which is why it is working the way you are seeing. The only way to make the two systems act identically would be for it to simply drop all of the command line arguments when <code>shell=True</code> on Windows.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload