@@ -358,20 +358,15 @@ functions.
358358
359359 Arguments are:
360360
361- *args * should be a string, or a sequence of program arguments. The program
362- to execute is normally the first item in the args sequence or the string if
363- a string is given, but can be explicitly set by using the *executable *
364- argument. When *executable * is given, the first item in the args sequence
365- is still treated by most programs as the command name, which can then be
366- different from the actual executable name. On Unix, it becomes the display
367- name for the executing program in utilities such as :program: `ps `.
368-
369- On Unix, with *shell=False * (default): In this case, the Popen class uses
370- :meth: `os.execvp ` like behavior to execute the child program.
371- *args * should normally be a
372- sequence. If a string is specified for *args *, it will be used as the name
373- or path of the program to execute; this will only work if the program is
374- being given no arguments.
361+ *args * should be a sequence of program arguments or else a single string.
362+ By default, the program to execute is the first item in *args * if *args * is
363+ a sequence and the string itself if *args * is a string. However, see the
364+ *shell * and *executable * arguments for differences from this behavior.
365+
366+ On Unix, the :class: `Popen ` class uses :meth: `os.execvp `-like behavior to
367+ execute the child program. If *args * is a string, the string is
368+ interpreted as the name or path of the program to execute; this only works
369+ if the program is being given no arguments.
375370
376371 .. note ::
377372
@@ -392,13 +387,23 @@ functions.
392387 used in the shell (such as filenames containing spaces or the *echo * command
393388 shown above) are single list elements.
394389
395- On Unix, with *shell=True *: If args is a string, it specifies the command
396- string to execute through the shell. This means that the string must be
390+ On Windows, the :class: `Popen ` class uses ``CreateProcess() `` to
391+ execute the child program, which operates on strings. If *args * is a
392+ sequence, it will be converted to a string in a manner described in
393+ :ref: `converting-argument-sequence `.
394+
395+ The *shell * argument (which defaults to *False *) specifies whether to use
396+ the shell as the program to execute. It is recommended to pass *args * as a
397+ sequence if *shell * is *False * and as a string if *shell * is *True *.
398+
399+ On Unix with ``shell=True ``, the shell defaults to :file: `/bin/sh `. If
400+ *args * is a string, the string specifies the command
401+ to execute through the shell. This means that the string must be
397402 formatted exactly as it would be when typed at the shell prompt. This
398403 includes, for example, quoting or backslash escaping filenames with spaces in
399404 them. If *args * is a sequence, the first item specifies the command string, and
400405 any additional items will be treated as additional arguments to the shell
401- itself. That is to say, * Popen * does the equivalent of::
406+ itself. That is to say, :class: ` Popen ` does the equivalent of::
402407
403408 Popen(['/bin/sh', '-c', args[0], args[1], ...])
404409
@@ -408,10 +413,11 @@ functions.
408413 input. See the warning under :ref: `frequently-used-arguments `
409414 for details.
410415
411- On Windows: the :class: `Popen ` class uses CreateProcess() to execute the
412- child program, which operates on strings. If *args * is a sequence, it will
413- be converted to a string in a manner described in
414- :ref: `converting-argument-sequence `.
416+ On Windows with ``shell=True ``, the :envvar: `COMSPEC ` environment variable
417+ specifies the default shell. The only time you need to specify
418+ ``shell=True `` on Windows is when the command you wish to execute is built
419+ into the shell (e.g. :command: `dir ` or :command: `copy `). You do not need
420+ ``shell=True `` to run a batch file or console-based executable.
415421
416422 *bufsize *, if given, has the same meaning as the corresponding argument to the
417423 built-in open() function: :const: `0 ` means unbuffered, :const: `1 ` means line
@@ -425,15 +431,14 @@ functions.
425431 enable buffering by setting *bufsize * to either -1 or a large enough
426432 positive value (such as 4096).
427433
428- The *executable * argument specifies the program to execute. It is very seldom
429- needed: Usually, the program to execute is defined by the *args * argument. If
430- ``shell=True ``, the *executable * argument specifies which shell to use. On Unix,
431- the default shell is :file: `/bin/sh `. On Windows, the default shell is
432- specified by the :envvar: `COMSPEC ` environment variable. The only reason you
433- would need to specify ``shell=True `` on Windows is where the command you
434- wish to execute is actually built in to the shell, eg ``dir ``, ``copy ``.
435- You don't need ``shell=True `` to run a batch file, nor to run a console-based
436- executable.
434+ The *executable * argument specifies a replacement program to execute. It
435+ is very seldom needed. When ``shell=False ``, *executable * replaces the
436+ program to execute specified by *args *. However, the *args * program is
437+ still treated by most programs as the command name, which can then be
438+ different from the program actually executed. On Unix, the *args * name
439+ becomes the display name for the executable in utilities such as
440+ :program: `ps `. If ``shell=True ``, on Unix the *executable * argument
441+ specifies a replacement shell for the default :file: `/bin/sh `.
437442
438443 *stdin *, *stdout * and *stderr * specify the executed program's standard input,
439444 standard output and standard error file handles, respectively. Valid values
0 commit comments