mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
nsh: Add pipeline support for nsh commandline
And nested pipeline supported.
Test
1. Redirect in
cat < /etc/init.d/rc.sysinit
2. Simple pipeline
ls | cat
3. Nested pipeline
ls | dd | cat | dd | cat
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
3da204c23e
commit
c052bd8377
4 changed files with 186 additions and 1 deletions
|
|
@ -158,6 +158,19 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
|||
goto errout_with_actions;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_NSH_PIPELINE
|
||||
else if (param->fd_in != -1)
|
||||
{
|
||||
ret = posix_spawn_file_actions_adddup2(&file_actions,
|
||||
param->fd_in, 0);
|
||||
if (ret != 0)
|
||||
{
|
||||
serr("ERROR: posix_spawn_file_actions_adddup2 failed: %d\n",
|
||||
ret);
|
||||
goto errout_with_actions;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Is output being redirected? */
|
||||
|
||||
|
|
@ -175,6 +188,19 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
|||
goto errout_with_actions;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_NSH_PIPELINE
|
||||
else if (param->fd_out != -1)
|
||||
{
|
||||
ret = posix_spawn_file_actions_adddup2(&file_actions,
|
||||
param->fd_out, 1);
|
||||
if (ret != 0)
|
||||
{
|
||||
serr("ERROR: posix_spawn_file_actions_adddup2 failed: %d\n",
|
||||
ret);
|
||||
goto errout_with_actions;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIBC_EXECFUNCS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue