exec
exec(*args)
public
Replaces the current process by running the given external command. command… is one of following forms.
commandline : command line string which is passed to the standard shell cmdname, arg1, ... : command name and one or more arguments (no shell) [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
If single string is given as the command, it is taken as a command line that is subject to shell expansion before being executed.
The standard shell means always “/bin/sh” on Unix-like systems, ENV[“RUBYSHELL”] or ENV[“COMSPEC”] on Windows NT series, and similar.
If two or more string given, the first is taken as a command name and the rest are passed as parameters to command with no shell expansion.
If a two-element array at the beginning of the command, the first element is the command to be executed, and the second argument is used as the argv[0] value, which may show up in process listings.
In order to execute the command, one of the exec(2) system calls is used, so the running command may inherit some of the environment of the original program (including open file descriptors). This behavior is modified by env and options. See spawn for details.
Raises SystemCallError if the command couldn’t execute (typically Errno::ENOENT when it was not found).
exec "echo *" # echoes list of files in current directory # never get here exec "echo", "*" # echoes an asterisk # never get here