From 99778934c125ff4ede23f5949490cc67c522c2d1 Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Fri, 9 Jul 2004 18:40:42 +0000 Subject: [PATCH] Ensure that redirection is off before attempting to read next line. --- src/iocsh/iocsh.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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.