Skip to content

Commit 2defa9f

Browse files
committed
[DOC] Elaborate exceptional behaviors on Windows
1 parent 769bb92 commit 2defa9f

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

process.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8919,13 +8919,8 @@ proc_warmup(VALUE _)
89198919
*
89208920
* < C* | $SHELL >
89218921
*
8922-
* However, on different OSes, different things are provided as
8923-
* built-in commands. An example of this is +'echo'+, which is a
8924-
* built-in on Windows, but is a normal program on Linux and Mac OS X.
8925-
* This means that <code>Process.spawn 'echo', '%Path%'</code> will
8926-
* display the contents of the <tt>%Path%</tt> environment variable on
8927-
* Windows, but <code>Process.spawn 'echo', '$PATH'</code> prints the
8928-
* literal <tt>$PATH</tt>.
8922+
* However, there are exceptions on Windows. See {Execution Shell on
8923+
* Windows}[rdoc-ref:Process@Execution+Shell+on+Windows].
89298924
*
89308925
* If you want to invoke a path containing spaces with no arguments
89318926
* without shell, you will need to use a 2-element array +exe_path+.
@@ -9082,10 +9077,27 @@ proc_warmup(VALUE _)
90829077
*
90839078
* /bin/bash: CONTRIBUTING.md COPYING COPYING.ja
90849079
*
9080+
* === Execution Shell on Windows
9081+
*
90859082
* On Windows, the shell invoked is determined by environment variable
9086-
* +RUBYSHELL+, if defined, or +COMSPEC+ otherwise. The standard
9087-
* shell +cmd.exe+ performs environment variable expansion but does
9088-
* not have globbing functionality:
9083+
* +RUBYSHELL+, if defined, or +COMSPEC+ otherwise; the entire string
9084+
* +command_line+ is passed as an argument to <tt>-c</tt> option for
9085+
* +RUBYSHELL+, as well as <tt>/bin/sh</tt>, and {/c
9086+
* option}[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd]
9087+
* for +COMSPEC+. The shell is invoked automatically in the following
9088+
* cases:
9089+
*
9090+
* - The command is a built-in of +cmd.exe+, such as +echo+.
9091+
* - The executable file is a batch file; its name ends with +.bat+ or
9092+
* +.cmd+.
9093+
*
9094+
* Note that the command will still be invoked as +command_line+ form
9095+
* even when called in +exe_path+ form, because +cmd.exe+ does not
9096+
* accept a script name like <tt>/bin/sh</tt> does but only works with
9097+
* <tt>/c</tt> option.
9098+
*
9099+
* The standard shell +cmd.exe+ performs environment variable
9100+
* expansion but does not have globbing functionality:
90899101
*
90909102
* Example:
90919103
*

0 commit comments

Comments
 (0)