NSH: Loosen up if-then-else-fi syntx so that a command can be on the same line as the 'then' and 'else' tokens. This allows, as an example, 'if true; then echo true; else echo false; fi' which is much more bash-like
This commit is contained in:
parent
df7b5a7059
commit
1b3a763e4b
|
@ -618,15 +618,34 @@ fi
|
|||
|
||||
<p>
|
||||
<code>while-do-done</code> and <code>until-do-done</code> looping constructs are also supported.
|
||||
These works from the command line but are primarily intended for use within NSH scripts
|
||||
These work from the command line but are primarily intended for use within NSH scripts
|
||||
(see the <a href="#cmdsh"><code>sh</code></a> command).
|
||||
The syntax is as follows:
|
||||
</p>
|
||||
<ul><dl>
|
||||
<dt><code>while <test-cmd>; do <cmd-sequence>; done</code></dt>
|
||||
<dd>Execute <code><cmd-sequence></code> as long as <code><test-cmd></code> has an exit status of zero.</dd>
|
||||
<dt><code>until <test-cmd>; do <cmd-sequence>; done</code></dt>
|
||||
<dd>Execute <code><cmd-sequence></code> as long as <code><test-cmd></code> has a non-zero exit status.</dd>
|
||||
<ul>
|
||||
<li>
|
||||
<p><b><code>while-do-done</code></b>.
|
||||
Execute <code>[sequence of <cmd>]</code> as long as <code><cmd></code> has an exit status of zero.
|
||||
The syntax is as follows:
|
||||
<ul><pre>
|
||||
while <cmd>
|
||||
do
|
||||
[sequence of <cmd>]
|
||||
done
|
||||
</pre></ul>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><b><code>until-do-done</code></b>
|
||||
Execute <code>[sequence of <cmd>]</code> as long as <code><cmd></code> has a non-zero exit status.
|
||||
The syntax is as follows:
|
||||
<ul><pre>
|
||||
while <cmd>
|
||||
do
|
||||
[sequence of <cmd>]
|
||||
done
|
||||
</pre></ul>
|
||||
</p>
|
||||
</li>
|
||||
</dl></ul>
|
||||
|
||||
<table width ="100%">
|
||||
|
|
Loading…
Reference in New Issue