mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
nsh: return EOF when nread is 0
If enable CONFIG NSH_CLE. When sh reads data and detects that nread is 0, return EOF and exit. Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
This commit is contained in:
parent
2bc4bdadee
commit
f82e6c2229
2 changed files with 8 additions and 7 deletions
|
|
@ -211,11 +211,12 @@ int nsh_session(FAR struct console_stdio_s *pstate,
|
|||
|
||||
ret = cle_fd(pstate->cn_line, nsh_prompt(), LINE_MAX,
|
||||
INFD(pstate), OUTFD(pstate));
|
||||
if (ret < 0)
|
||||
if (ret == EOF)
|
||||
{
|
||||
dprintf(ERRFD(pstate), g_fmtcmdfailed, "nsh_session",
|
||||
"cle", NSH_ERRNO_OF(-ret));
|
||||
continue;
|
||||
ret = EXIT_SUCCESS;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
/* Display the prompt string */
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ static int cle_getch(FAR struct cle_s *priv)
|
|||
if (nread == 0 || errcode != EINTR)
|
||||
{
|
||||
cledbg("ERROR: read from stdin failed: %d\n", errcode);
|
||||
return -EIO;
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -372,13 +372,13 @@ static void cle_setcursor(FAR struct cle_s *priv, int16_t column)
|
|||
int len;
|
||||
int off;
|
||||
|
||||
/* Sub prompt offset from real postion to get correct offset to execute */
|
||||
/* Sub prompt offset from real position to get correct offset to execute */
|
||||
|
||||
off = column - (priv->realpos - priv->coloffs);
|
||||
|
||||
cleinfo("column=%d offset=%d\n", column, off);
|
||||
|
||||
/* If cursor not move, retrun directly */
|
||||
/* If cursor not move, return directly */
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
|
|
@ -703,9 +703,9 @@ static int cle_editloop(FAR struct cle_s *priv)
|
|||
for (; ; )
|
||||
{
|
||||
ch = cle_getch(priv);
|
||||
if (ch < 0)
|
||||
if (ch == EOF)
|
||||
{
|
||||
return -EIO;
|
||||
return EOF;
|
||||
}
|
||||
else if (state != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue