summaryrefslogtreecommitdiffstats
path: root/common/parser.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2015-10-11 11:43:41 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2015-10-15 08:56:21 +0200
commit04d8c2541d427a04875b7ae4a5862ea567f56df0 (patch)
treef0235b64a3bcc1a90ddc0055d75cd46740fd0fa6 /common/parser.c
parent822ad01d5db8e530f70d76ac9da0b2730279bfb4 (diff)
downloadbarebox-04d8c2541d427a04875b7ae4a5862ea567f56df0.tar.gz
common/parser.c: Do not treat zero return code as error
Run_command() would return zero to indicated success so treating it as error case would completely break command repetition logic, so change comparinson operator from "less or equal" to "less then" Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/parser.c')
-rw-r--r--common/parser.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/common/parser.c b/common/parser.c
index 2b95aed..6136dbf 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -266,7 +266,6 @@ int run_shell(void)
{
static char lastcommand[CONFIG_CBSIZE] = { 0, };
int len;
- int rc = 1;
login();
@@ -276,14 +275,14 @@ int run_shell(void)
if (len > 0)
strcpy (lastcommand, console_buffer);
- if (len == -1)
+ if (len == -1) {
puts ("<INTERRUPT>\n");
- else
- rc = run_command(lastcommand);
-
- if (rc <= 0) {
- /* invalid command or not repeatable, forget it */
- lastcommand[0] = 0;
+ } else {
+ const int rc = run_command(lastcommand);
+ if (rc < 0) {
+ /* invalid command or not repeatable, forget it */
+ lastcommand[0] = 0;
+ }
}
}
return 0;