Skip to content

Commit 6230586

Browse files
committed
[DOC] Add Argument args subsection
1 parent be6e06e commit 6230586

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

process.c

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,9 @@ NORETURN(static VALUE f_exec(int c, const VALUE *a, VALUE _));
31143114
*
31153115
* Sat Aug 26 09:38:00 AM CDT 2023
31163116
*
3117-
* Ruby invokes the executable directly, with no shell and no shell expansion:
3117+
* Ruby invokes the executable directly.
3118+
* This form does not use the shell;
3119+
* see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
31183120
*
31193121
* exec('doesnt_exist') # Raises Errno::ENOENT
31203122
*
@@ -4820,7 +4822,9 @@ rb_spawn(int argc, const VALUE *argv)
48204822
* system('foo') # => nil
48214823
* $? # => #<Process::Status: pid 645608 exit 127>
48224824
*
4823-
* Ruby invokes the executable directly, with no shell and no shell expansion:
4825+
* Ruby invokes the executable directly.
4826+
* This form does not use the shell;
4827+
* see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
48244828
*
48254829
* system('doesnt_exist') # => nil
48264830
*
@@ -4985,7 +4989,7 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
49854989
*
49864990
* Ruby invokes the executable directly.
49874991
* This form does not use the shell;
4988-
* see below for caveats.
4992+
* see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
49894993
*
49904994
* If one or more +args+ is given, each is an argument or option
49914995
* to be passed to the executable:
@@ -5000,14 +5004,6 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
50005004
* C*
50015005
* hello world
50025006
*
5003-
* The 'cmdname, arg1, ...' form does not use the shell. However,
5004-
* on different OSes, different things are provided as built-in
5005-
* commands. An example of this is 'echo', which is a built-in
5006-
* on Windows, but is a normal program on Linux and Mac OS X.
5007-
* This means that `Process.spawn 'echo', '%Path%'` will display
5008-
* the contents of the `%Path%` environment variable on Windows,
5009-
* but `Process.spawn 'echo', '$PATH'` prints the literal '$PATH'.
5010-
*
50115007
* Raises an exception if the new process could not execute.
50125008
*/
50135009

@@ -8843,7 +8839,7 @@ proc_warmup(VALUE _)
88438839
* or if it contains one or more meta characters.
88448840
* - +exe_path+ otherwise.
88458841
*
8846-
* <b>Argument +command_line+</b>
8842+
* ==== Argument +command_line+
88478843
*
88488844
* \String argument +command_line+ is a command line to be passed to a shell;
88498845
* it must begin with a shell reserved word, begin with a special built-in,
@@ -8865,7 +8861,7 @@ proc_warmup(VALUE _)
88658861
*
88668862
* See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
88678863
*
8868-
* <b>Argument +exe_path+</b>
8864+
* ==== Argument +exe_path+
88698865
*
88708866
* Argument +exe_path+ is one of the following:
88718867
*
@@ -8892,6 +8888,40 @@ proc_warmup(VALUE _)
88928888
*
88938889
* "Hello! 1\n"
88948890
*
8891+
* === Arguments +args+
8892+
*
8893+
* If +command_line+ does not contain shell meta characters except for
8894+
* spaces and tabs, or +exe_path+ is given, Ruby invokes the
8895+
* executable directly. This form does not use the shell:
8896+
*
8897+
* spawn("doesnt_exist") # Raises Errno::ENOENT
8898+
* spawn("doesnt_exist", "\n") # Raises Errno::ENOENT
8899+
*
8900+
* spawn("doesnt_exist\n") # => false
8901+
* # sh: 1: doesnot_exist: not found
8902+
*
8903+
* The error message is from a shell and would vary depending on your
8904+
* system.
8905+
*
8906+
* If one or more +args+ is given after +exe_path+, each is an
8907+
* argument or option to be passed to the executable:
8908+
*
8909+
* Example:
8910+
*
8911+
* system('echo', '<', 'C*', '|', '$SHELL', '>') # => true
8912+
*
8913+
* Output:
8914+
*
8915+
* < C* | $SHELL >
8916+
*
8917+
* However, on different OSes, different things are provided as
8918+
* built-in commands. An example of this is +'echo'+, which is a
8919+
* built-in on Windows, but is a normal program on Linux and Mac OS X.
8920+
* This means that <code>Process.spawn 'echo', '%Path%'</code> will
8921+
* display the contents of the <tt>%Path%</tt> environment variable on
8922+
* Windows, but <code>Process.spawn 'echo', '$PATH'</code> prints the
8923+
* literal <tt>$PATH</tt>.
8924+
*
88958925
* === Execution Options
88968926
*
88978927
* Optional trailing argument +options+ is a hash of execution options.

0 commit comments

Comments
 (0)