]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
fix & enhance vlclient command-line handling
authorMax Cohan <max@endpoint.com>
Wed, 30 Jun 2010 08:30:49 +0000 (09:30 +0100)
committerDerrick Brashear <shadow@dementia.org>
Wed, 30 Jun 2010 12:23:58 +0000 (05:23 -0700)
Corrects an EOL bug in vlclient and adds a more user-friendly
handling of request for help (i.e., '-help' now works)

FIXES 125036

Change-Id: I70f6523d538e34a02536e482f99916293a195df5
Reviewed-on: http://gerrit.openafs.org/2300
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/vlserver/vlclient.c

index 823d7d61651f7fa6c351d50a39a020fed0c10315..e15f94bdea57ab639cca93f30b4937c2e107e8f2 100644 (file)
@@ -242,10 +242,19 @@ handleit(struct cmd_syndesc *as, void *arock)
        } else {
            char *oper, *vname;
            register char **argp = args;
+
+           /* Eliminate terminating CR */
+           while(strlen(line) > 0 &&
+                (line[strlen(line)-1] == '\n' ||
+                 line[strlen(line)-1] == '\r')) {
+             line[strlen(line)-1] = NULL;
+           }
+
            GetArgs(line, argp, &nargs);
            oper = &argp[0][0];
            ++argp, --nargs;
-           if (!strcmp(oper, "cr")) {
+           if (!*line) {
+           } else if (!strcmp(oper, "cr")) {
                fill_entry(&entry, argp, nargs);
                display_entry(&entry, 0);
                code = ubik_VL_CreateEntry(cstruct, 0, &entry);
@@ -1004,12 +1013,13 @@ handleit(struct cmd_syndesc *as, void *arock)
                    printf("VL_ChangeAddr returned code = %d\n", code);
                    continue;
                }
-           } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h"))
+           } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h") || !strcmp(oper, "help"))
                print_usage();
            else if ((!strcmp(oper, "q")) || !strcmp(oper, "quit"))
                exit(0);
            else {
-               printf("Unknown oper!\n");
+               printf("Unknown oper (%s)!\n", oper);
+               print_usage();
            }
        }
     }