summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-29 21:09:30 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-29 21:09:30 -0400
commit758bb619e8631be1773cbecb4226580c83a41651 (patch)
treee3579bc9c916dcdbfa15a8b6c435e4793f16e593 /exec.c
parent803edcab57b8d90897f9bc96affe8b4fb0ba468a (diff)
downloadbfs-758bb619e8631be1773cbecb4226580c83a41651.tar.xz
exec: Fix more corner cases with -ok ... +
-ok should look for a ; even if it sees {} +, according to POSIX.
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/exec.c b/exec.c
index 250bba7..42deccf 100644
--- a/exec.c
+++ b/exec.c
@@ -127,21 +127,22 @@ struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const st
for (i = 1; ; ++i) {
const char *arg = argv[i];
if (!arg) {
- cfprintf(cerr, "%{er}error: %s: Expected ';' or '+'.%{rs}\n", argv[0]);
+ if (execbuf->flags & BFS_EXEC_CONFIRM) {
+ cfprintf(cerr, "%{er}error: %s: Expected '... ;'.%{rs}\n", argv[0]);
+ } else {
+ cfprintf(cerr, "%{er}error: %s: Expected '... ;' or '... {} +'.%{rs}\n", argv[0]);
+ }
goto fail;
} else if (strcmp(arg, ";") == 0) {
break;
- } else if (strcmp(arg, "+") == 0 && strcmp(argv[i - 1], "{}") == 0) {
- execbuf->flags |= BFS_EXEC_MULTI;
- break;
+ } else if (strcmp(arg, "+") == 0) {
+ if (!(execbuf->flags & BFS_EXEC_CONFIRM) && strcmp(argv[i - 1], "{}") == 0) {
+ execbuf->flags |= BFS_EXEC_MULTI;
+ break;
+ }
}
}
- if ((execbuf->flags & BFS_EXEC_CONFIRM) && (execbuf->flags & BFS_EXEC_MULTI)) {
- cfprintf(cerr, "%{er}error: %s ... + is not supported.%{rs}\n", argv[0]);
- goto fail;
- }
-
execbuf->tmpl_argv = argv + 1;
execbuf->tmpl_argc = i - 1;