Skip to content

Commit bc73779

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
nshlib/nsh_parse: Fix "e" flag not take effect
The NSH exits when a command exits with a non-zero status, even if the "e" flag is not set. This error does not exist in NSH scripts. Without this patch: nsh> sh -c "set -e; mkdir /test; echo $?" nsh: /test: mkdir failed: 17 nsh> sh -c "set +e; mkdir /test; echo $?" nsh: /test: mkdir failed: 17 nsh> rm /test nsh> sh -c "set +e; mkdir /test; echo $?" 0 With this patch: nsh> sh -c "set -e; mkdir /test; echo $?" nsh: /test: mkdir failed: 17 nsh> sh -c "set +e; mkdir /test; echo $?" nsh: /test: mkdir failed: 17 1 nsh> rm /test nsh> sh -c "set +e; mkdir /test; echo $?" 0 Signed-off-by: wangjianyu3 <[email protected]>
1 parent 00911d4 commit bc73779

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nshlib/nsh_parse.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,11 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
29362936
/* Parse this command */
29372937

29382938
ret = nsh_parse_command(vtbl, start);
2939-
if (ret != OK)
2939+
if (ret != OK
2940+
#ifndef CONFIG_NSH_DISABLESCRIPT
2941+
&& !(vtbl->np.np_flags & NSH_PFLAG_IGNORE)
2942+
#endif
2943+
)
29402944
{
29412945
/* nsh_parse_command may return (1) -1 (ERROR) meaning that the
29422946
* command failed or we failed to start the command application

0 commit comments

Comments
 (0)