From 1b3a763e4bb088ccd3c5776e4e39dddad3532e63 Mon Sep 17 00:00:00 2001 From: Gregory Nutt <gnutt@nuttx.org> Date: Fri, 17 Jan 2014 18:03:23 -0600 Subject: [PATCH] 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 --- Documentation/NuttShell.html | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html index 603ae759d7..2eeed4e678 100644 --- a/Documentation/NuttShell.html +++ b/Documentation/NuttShell.html @@ -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%"> -- GitLab