]> git.neil.brown.name Git - lafs-utils.git/commitdiff
lafs: allow "--tag value" as well as "--tag=value"
authorNeilBrown <neilb@suse.de>
Fri, 18 Mar 2011 05:34:08 +0000 (16:34 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 18 Mar 2011 05:34:08 +0000 (16:34 +1100)
... as fingers seem like this pattern too.

Signed-off-by: NeilBrown <neilb@suse.de>
tools/lafs.c

index 0616e2857e9ffe147e35bfe7714f53bd8bdd42b9..0c7360cd574dbe775f8392cc922ad75af2844238 100644 (file)
@@ -279,6 +279,14 @@ static void **parse_line(struct args **argsp, char *line, int *offsetp,
                        } else {
                                if (*e == '=')
                                        w = e+1;
+                               else if (args[n].type != flag) {
+                                       w = take_word(&line);
+                                       if (!w) {
+                                               asprintf(error,
+                                                        "Missing value for --%s", t);
+                                               break;
+                                       }
+                               }
                                rv[n+offset] = w;
                                rv[n2+offset] = w;
                        }
@@ -563,15 +571,21 @@ static char **complete_in_context(const char *prefix, int start, int end)
        args = lafs_args;
        arglist = parse_line(&args, line, &offset, &last, &error);
 
+       if (last >= 0 &&
+           error && strncmp(error, "Missing value for", 17) == 0) {
+               free(error);
+               error = 0;
+       } else if (!(start && rl_line_buffer[start-1] == '='))
+               last = -1;
+
        if (error) {
                printf("\n *** %s ***\n", error);
                free(error);
                goto after_message;
        }
 
-       if (start && rl_line_buffer[start-1] == '=' &&
-           last >= 0 && arglist[last+offset] &&
-           ((char*)arglist[last+offset])[0] == '\0')
+       if (last >= 0 && (arglist[last+offset] == NULL ||
+                         ((char*)arglist[last+offset])[0] == '\0'))
                p = last;
        else {
                last = -1;