diff --git a/src/iocsh/iocsh.cpp b/src/iocsh/iocsh.cpp index 1f4b26471..3e3192eed 100644 --- a/src/iocsh/iocsh.cpp +++ b/src/iocsh/iocsh.cpp @@ -420,8 +420,7 @@ iocsh (const char *pathname) argc = 0; wasOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf()); epicsThreadSetOkToBlock(epicsThreadGetIdSelf(), 1); - while ((raw = epicsReadline(prompt, readlineContext)) != NULL) { - lineno++; + for (;;) { /* * Undo redirection @@ -435,6 +434,13 @@ iocsh (const char *pathname) } stopRedirect(filename, lineno, redirects); + /* + * Read a line + */ + if ((raw = epicsReadline(prompt, readlineContext)) == NULL) + break; + lineno++; + /* * Ignore comment lines other than to echo * them if they came from a script.