From 4f8b0d0a714a7f8302e876e217e8f49e2c5901d5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 17 Jan 2014 18:03:23 -0600 Subject: 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 --- apps/nshlib/nsh_parse.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'apps/nshlib/nsh_parse.c') diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index a612e892a..c7505f34d 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -1684,14 +1684,9 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, else if (strcmp(cmd, "then") == 0) { - /* Get the cmd following the "then" -- there shouldn't be one */ + /* Get the cmd following the "then" -- there may or may not be one */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "then"); - goto errout; - } /* Verify that "then" is valid in this context */ @@ -1708,14 +1703,9 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, else if (strcmp(cmd, "else") == 0) { - /* Get the cmd following the "else" -- there shouldn't be one */ + /* Get the cmd following the "else" -- there may or may not be one */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "else"); - goto errout; - } /* Verify that "else" is valid in this context */ -- cgit v1.2.3