PATH:
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Kernel
U:RDoc::AnyMethod[iI"system:ETI"Kernel#system;TF:publico:RDoc::Markup::Document:@parts[Do:RDoc::Markup::Paragraph; [I"?Creates a new child process by doing one of the following ;TI"in that process:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"0Passing string +command_line+ to the shell.;To;;0; [o; ; [I"+Invoking the executable at +exe_path+.;T@o; ; [I"XThis method has potential security vulnerabilities if called with untrusted input; ;TI">see {Command Injection}[rdoc-ref:command_injection.rdoc].;T@o; ; [I" Returns:;T@o;; ;;[o;;0; [o; ; [I"2+true+ if the command exits with status zero.;To;;0; [o; ; [I"6+false+ if the exit status is a non-zero integer.;To;;0; [o; ; [I",+nil+ if the command could not execute.;T@o; ; [I"ARaises an exception (instead of returning +false+ or +nil+) ;TI"6if keyword argument +exception+ is set to +true+.;T@o; ; [I"7Assigns the command's error status to <tt>$?</tt>.;T@o; ; [ I"*The new process is created using the ;TI"o{system system call}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/system.html]; ;TI"Eit may inherit some of its environment from the calling program ;TI"0(possibly including open file descriptors).;T@o; ; [I"QArgument +env+, if given, is a hash that affects +ENV+ for the new process; ;TI"Isee {Execution Environment}[rdoc-ref:Process@Execution+Environment].;T@o; ; [I"BArgument +options+ is a hash of options for the new process; ;TI"Asee {Execution Options}[rdoc-ref:Process@Execution+Options].;T@o; ; [I"9The first required argument is one of the following:;T@o;; ;;[o;;0; [o; ; [I"'+command_line+ if it is a string, ;TI"Fand if it begins with a shell reserved word or special built-in, ;TI"3or if it contains one or more meta characters.;To;;0; [o; ; [I"+exe_path+ otherwise.;T@o; ; [I"#<b>Argument +command_line+</b>;T@o; ; [I"P\String argument +command_line+ is a command line to be passed to a shell; ;TI"Nit must begin with a shell reserved word, begin with a special built-in, ;TI" or contain meta characters:;T@o:RDoc::Markup::Verbatim; [ I"Wsystem('if true; then echo "Foo"; fi') # => true # Shell reserved word. ;TI"Lsystem('exit') # => true # Built-in. ;TI"[system('date > /tmp/date.tmp') # => true # Contains meta character. ;TI"@system('date > /nop/date.tmp') # => false ;TI"Lsystem('date > /nop/date.tmp', exception: true) # Raises RuntimeError. ;T:@format0o; ; [I"7Assigns the command's error status to <tt>$?</tt>:;T@o;; [ I"Gsystem('exit') # => true # Built-in. ;TI"[$? # => #<Process::Status: pid 640610 exit 0> ;TI";system('date > /nop/date.tmp') # => false ;TI"[$? # => #<Process::Status: pid 640742 exit 2> ;T;0o; ; [I"MThe command line may also contain arguments and options for the command:;T@o;; [I"$system('echo "Foo"') # => true ;T;0o; ; [I"Output:;T@o;; [I" Foo ;T;0o; ; [I"YSee {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.;T@o; ; [I">Raises an exception if the new process could not execute.;T@o; ; [I"<b>Argument +exe_path+</b>;T@o; ; [I"1Argument +exe_path+ is one of the following:;T@o;; ;;[o;;0; [o; ; [I"3The string path to an executable to be called.;To;;0; [o; ; [I"<A 2-element array containing the path to an executable ;TI"Dand the string to be used as the name of the executing process.;T@o; ; [I" Example:;T@o;; [I"Lsystem('/usr/bin/date') # => true # Path to date on Unix-style system. ;TI"9system('foo') # => nil # Command failed. ;T;0o; ; [I"Output:;T@o;; [I"%Mon Aug 28 11:43:10 AM CDT 2023 ;T;0o; ; [I"7Assigns the command's error status to <tt>$?</tt>:;T@o;; [ I"'system('/usr/bin/date') # => true ;TI"H$? # => #<Process::Status: pid 645605 exit 0> ;TI"&system('foo') # => nil ;TI"J$? # => #<Process::Status: pid 645608 exit 127> ;T;0o; ; [I"+Ruby invokes the executable directly. ;TI"'This form does not use the shell; ;TI"Gsee {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.;T@o;; [I"%system('doesnt_exist') # => nil ;T;0o; ; [I"CIf one or more +args+ is given, each is an argument or option ;TI"$to be passed to the executable:;T@o;; [I"0system('echo', 'C*') # => true ;TI"0system('echo', 'hello', 'world') # => true ;T;0o; ; [I"Output:;T@o;; [I"C* ;TI"hello world ;T;0o; ; [I">Raises an exception if the new process could not execute.;T: @fileI"process.c;T:0@omit_headings_from_table_of_contents_below0I"�system([env, ] command_line, options = {}, exception: false) -> true, false, or nil system([env, ] exe_path, *args, options = {}, exception: false) -> true, false, or nil ;T0[ I"(*args);T@�FI"Kernel;TcRDoc::NormalModule00
[+]
..
[-] loop-i.ri
[edit]
[-] Complex-i.ri
[edit]
[-] Pathname-i.ri
[edit]
[-] block_given%3f-i.ri
[edit]
[-] format-i.ri
[edit]
[-] readlines-i.ri
[edit]
[-] chop-i.ri
[edit]
[-] tap-i.ri
[edit]
[-] Hash-i.ri
[edit]
[-] catch-i.ri
[edit]
[-] warn-i.ri
[edit]
[-] exec-i.ri
[edit]
[-] iterator%3f-i.ri
[edit]
[-] Float-i.ri
[edit]
[-] spawn-i.ri
[edit]
[-] require_relative-i.ri
[edit]
[-] yield_self-i.ri
[edit]
[-] __method__-i.ri
[edit]
[-] %60-i.ri
[edit]
[-] caller_locations-i.ri
[edit]
[-] syscall-i.ri
[edit]
[-] printf-i.ri
[edit]
[-] then-i.ri
[edit]
[-] clone-i.ri
[edit]
[-] gem-i.ri
[edit]
[-] global_variables-i.ri
[edit]
[-] set_trace_func-i.ri
[edit]
[-] eval-i.ri
[edit]
[-] exit%21-i.ri
[edit]
[-] String-i.ri
[edit]
[-] autoload-i.ri
[edit]
[-] p-i.ri
[edit]
[-] pp-c.ri
[edit]
[-] pretty_inspect-i.ri
[edit]
[-] class-i.ri
[edit]
[-] __callee__-i.ri
[edit]
[-] srand-i.ri
[edit]
[-] putc-i.ri
[edit]
[-] jj-i.ri
[edit]
[-] system-i.ri
[edit]
[-] trap-i.ri
[edit]
[-] lambda-i.ri
[edit]
[-] caller-i.ri
[edit]
[-] abort-i.ri
[edit]
[-] sprintf-i.ri
[edit]
[-] callcc-i.ri
[edit]
[-] readline-i.ri
[edit]
[-] sleep-i.ri
[edit]
[-] Array-i.ri
[edit]
[-] autoload%3f-i.ri
[edit]
[-] gsub-i.ri
[edit]
[-] proc-i.ri
[edit]
[-] puts-i.ri
[edit]
[-] trace_var-i.ri
[edit]
[-] pp-i.ri
[edit]
[-] rand-i.ri
[edit]
[-] JSON-i.ri
[edit]
[-] chomp-i.ri
[edit]
[-] __dir__-i.ri
[edit]
[-] y-i.ri
[edit]
[-] untrace_var-i.ri
[edit]
[-] gets-i.ri
[edit]
[-] Rational-i.ri
[edit]
[-] at_exit-i.ri
[edit]
[-] fork-i.ri
[edit]
[-] local_variables-i.ri
[edit]
[-] select-i.ri
[edit]
[-] fail-i.ri
[edit]
[-] Integer-i.ri
[edit]
[-] raise-i.ri
[edit]
[-] test-i.ri
[edit]
[-] URI-c.ri
[edit]
[-] exit-i.ri
[edit]
[-] throw-i.ri
[edit]
[-] cdesc-Kernel.ri
[edit]
[-] binding-i.ri
[edit]
[-] j-i.ri
[edit]
[-] frozen%3f-i.ri
[edit]
[-] URI-i.ri
[edit]
[-] load-i.ri
[edit]
[-] open-i.ri
[edit]
[-] sub-i.ri
[edit]
[-] require-i.ri
[edit]
[-] print-i.ri
[edit]