summaryrefslogtreecommitdiff
path: root/bin/ed/main.c
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2018-06-15 08:45:04 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2018-06-15 08:45:04 +0000
commit43b9fc544d178f6f35f6bc2c831f66154eac7bca (patch)
tree910803b9726e0b447d7475a6885100c2fc7490e4 /bin/ed/main.c
parent93376acf2a7665ab6fceca3344019ce6f92f5e28 (diff)
Make sure we always return more than a single '!' in get_shell_command.
This is similar to what vi/ex does and removes the final BACKWARDS flag. Behaviour requested by and OK tb@
Diffstat (limited to 'bin/ed/main.c')
-rw-r--r--bin/ed/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/bin/ed/main.c b/bin/ed/main.c
index bea5d438567..d01a3955eb3 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.64 2018/06/15 08:26:31 martijn Exp $ */
+/* $OpenBSD: main.c,v 1.65 2018/06/15 08:45:03 martijn Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
/* main.c: This file contains the main control and user-interface routines
@@ -983,11 +983,7 @@ get_shell_command(void)
REALLOC(buf, n, i + 1, ERR);
buf[i++] = *ibufp++;
}
-#ifdef BACKWARDS
- else if (shcmd == NULL || *(shcmd + 1) == '\0')
-#else
else if (shcmd == NULL)
-#endif
{
seterrmsg("no previous command");
return ERR;
@@ -1010,6 +1006,10 @@ get_shell_command(void)
s = ibufp++;
break;
}
+ if (i == 1) {
+ seterrmsg("no command");
+ return ERR;
+ }
REALLOC(shcmd, shcmdsz, i + 1, ERR);
memcpy(shcmd, buf, i);
shcmd[shcmdi = i] = '\0';