diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2021-04-20 16:34:21 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2021-04-20 16:34:21 +0000 |
commit | 02ab6ab4a68ca6fb46781d897098d166d8869e18 (patch) | |
tree | 22ee665cdaa52fac96075ad82c2b3a6a13d08cc9 | |
parent | 89c8c9a381127c0a97c8f4948cb50ee3dcd348fe (diff) |
Indicate if an mg function is unsuitable for a startup file (requires
user interaction).
-rw-r--r-- | usr.bin/mg/funmap.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/interpreter.c | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c index b9207c6b772..c6c59272ed8 100644 --- a/usr.bin/mg/funmap.c +++ b/usr.bin/mg/funmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: funmap.c,v 1.61 2021/04/20 10:02:50 lum Exp $ */ +/* $OpenBSD: funmap.c,v 1.62 2021/04/20 16:34:20 lum Exp $ */ /* This file is in the public domain */ @@ -34,7 +34,7 @@ static struct funmap *funs; * 0 = a toggle, non-modifiable insert/delete, region modifier, etc * 1 = value can be string or number value (like: file/buf name, search string) * 2 = multiple type value required, see auto-execute, or global-set-key, etc - * -1 = variable length # parameters (unused at moment) + * -1 = error: interactive commmand, unsuitable for interpreter * * Some functions when used interactively may ask for a 'y' or 'n' (or another * character) to continue, in excline, a 'y' is assumed. Functions like this @@ -168,9 +168,9 @@ static struct funmap functnames[] = { {prevwind, "previous-window", 0}, {spawncli, "push-shell", 0}, {showcwdir, "pwd", 0}, - {queryrepl, "query-replace", 1}, + {queryrepl, "query-replace", -1}, #ifdef REGEX - {re_queryrepl, "query-replace-regexp", 1}, + {re_queryrepl, "query-replace-regexp", -1}, #endif /* REGEX */ {quote, "quoted-insert", 1}, #ifdef REGEX diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c index e41da1c3696..3d6500be032 100644 --- a/usr.bin/mg/interpreter.c +++ b/usr.bin/mg/interpreter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interpreter.c,v 1.21 2021/04/20 14:26:19 lum Exp $ */ +/* $OpenBSD: interpreter.c,v 1.22 2021/04/20 16:34:20 lum Exp $ */ /* * This file is in the public domain. * @@ -370,6 +370,9 @@ parsexp(char *begp, const char *par1, const char *par2, int blkid, int expctr) if (numparams == 0) return (dobeep_msgs("Command takes no arguments:", cmdp)); + if (numparams == -1) + return (dobeep_msgs("Interactive command found:", cmdp)); + if ((e1 = malloc(sizeof(struct expentry))) == NULL) { cleanup(); return (dobeep_msg("malloc Error")); |