ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahz_5.4.0.1/simpcmds.htm

129 lines
4.5 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8">
<title>Simple commands</title>
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</HEAD>
<body bgcolor="#FFFFFF">
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h2>Simple commands</h2>
<p>A simple command is a sequence of optional variable assignments
and redirections followed by a command name. When a simple command
is recognized by <strong>qsh</strong>, it performs the following
actions:</p>
<ol>
<li>Leading words of the form name=value are stripped off and
assigned to the environment of the simple command. Redirection
operators and their arguments are saved for processing in step
3.</li>
<li>The remaining words are expanded as described in <a href=
"wordexp.htm">Word expansions</a>, and the first remaining word is
considered the command name. Any additional words are considered
the arguments of the command. If no command name is found, then the
name=value variable assignments recognized in step 1 affect the
current shell.</li>
<li>Redirections are performed as described in <a href=
"redirect.htm">Redirection</a>.</li>
</ol>
<strong>Path search</strong>
<p>If a simple command does not contain any slashes, <strong>
qsh</strong> finds the command by searching:</p>
<ol>
<li>for a special built-in utility of that name, then</li>
<li>for a shell function of that name, then</li>
<li>for a regular built-in utility of that name, then</li>
<li>each directory in the <strong>PATH</strong> variable in turn
for the regular utility.</li>
</ol>
<p>Command names containing a slash (<strong>/</strong>) are
run as a regular utility without performing any of the above
searches.</p>
<p><a name="builtin"></a>
A built-in utility is run internal to the shell, without
starting a new process. A special built-in utility is different
from a regular built-in utility in these respects:</p>
<ol>
<li>A syntax error in a special built-in utility causes a
non-interactive shell to exit.</li>
<li>Variable assignments specified with a special built-in utility
remain in effect after the utility completes.</li>
</ol>
<p>
These are the special built-in utilities: <a href="break.htm">
break</a>, <a href="colon.htm">colon</a>, <a href="continue.htm">
continue</a>, <a href="declare.htm">declare</a>,
<a href="dot.htm">dot</a>, <a href="eval.htm">
eval</a>, <a href="exec.htm">exec</a>, <a href="exit.htm">exit</a>,
<a href="export.htm">export</a>, <a href="local.htm">local</a>,
<a href="readonly.htm">readonly</a>, <a href="return.htm">return</a>,
<a href="set.htm">set</a>, <a href="shift.htm">shift</a>, <a href="source.htm">
source</a>, <a href="trap.htm">trap</a>, <a href="typeset.htm">
typeset</a>, and <a href="unset.htm">unset</a>.
</p>
<p>When a shell function is run, all of the shell positional
parameters (except the special parameter <strong>0</strong>, which
remains unchanged) are set to the arguments of the shell function.
The variables which are explicitly placed in the environment of the
command (by placing assignments to them before the function name)
are made local to the function and are set to the specified values.
The positional parameters are restored to their original values
when the shell function completes.</p>
<p><a name="regular"></a>
When a regular utility is run, <strong>qsh</strong> starts a new
process, passing the arguments and the environment to the program.
If the program is a shell script, <strong>qsh</strong> will
interpret the program in a subshell. <strong>qsh</strong> will
reinitialize itself in this case, so that the effect will be as if
a new shell had been invoked to handle the shell script.</p>
<p><strong>Command exit status</strong></p>
<p>Each command has an exit status that can influence the behavior
of other shell commands. By convention, a command exits with zero
for normal or success, and non-zero for failure, error, or a false
indication. The documentation for each command describes the exit
codes it returns and what they mean. The exit status can be one of
these values:</p>
<ul>
<li>0 for success.</li>
<li>1 to 125 for failure.</li>
<li>126 when <strong>qsh</strong> finds the command but it is not
executable.</li>
<li>127 when <strong>qsh</strong> cannot find the command.</li>
<li>128 and above when the command is ended by a signal. The value
is 128 plus the signal number.</li>
</ul>
</body>
</html>