Skip to content
Snippets Groups Projects
Commit 1b3a763e authored by Gregory Nutt's avatar Gregory Nutt
Browse files

NSH: Loosen up if-then-else-fi syntx so that a command can be on the same...

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
parent df7b5a70
No related branches found
No related tags found
No related merge requests found
...@@ -618,15 +618,34 @@ fi ...@@ -618,15 +618,34 @@ fi
<p> <p>
<code>while-do-done</code> and <code>until-do-done</code> looping constructs are also supported. <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). (see the <a href="#cmdsh"><code>sh</code></a> command).
The syntax is as follows:
</p> </p>
<ul><dl> <ul>
<dt><code>while &lt;test-cmd&gt;; do &lt;cmd-sequence&gt;; done</code></dt> <li>
<dd>Execute <code>&lt;cmd-sequence&gt;</code> as long as <code>&lt;test-cmd&gt;</code> has an exit status of zero.</dd> <p><b><code>while-do-done</code></b>.
<dt><code>until &lt;test-cmd&gt;; do &lt;cmd-sequence&gt;; done</code></dt> Execute <code>[sequence of &lt;cmd&gt;]</code> as long as <code>&lt;cmd&gt;</code> has an exit status of zero.
<dd>Execute <code>&lt;cmd-sequence&gt;</code> as long as <code>&lt;test-cmd&gt;</code> has a non-zero exit status.</dd> The syntax is as follows:
<ul><pre>
while &lt;cmd&gt;
do
[sequence of &lt;cmd&gt;]
done
</pre></ul>
</p>
</li>
<li>
<p><b><code>until-do-done</code></b>
Execute <code>[sequence of &lt;cmd&gt;]</code> as long as <code>&lt;cmd&gt;</code> has a non-zero exit status.
The syntax is as follows:
<ul><pre>
while &lt;cmd&gt;
do
[sequence of &lt;cmd&gt;]
done
</pre></ul>
</p>
</li>
</dl></ul> </dl></ul>
<table width ="100%"> <table width ="100%">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment