Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-9612

Fix -? option to wt utility commands

    • 3
    • StorEng - Defined Pipeline

      Summary

      Most (all?) of the command options to the wt utility are supposed to support a -? option that prints the usage for that command.  Due to coding bug, this option is not recognized, causing the wt utility to print an "illegal option" message and then, because of the illegal argument, print the command's usage.

      $ wt verify -?
      wt: illegal option -- ?
      usage: wt [-LmRrSVv] [-C config] [-E secretkey] [-h home] verify [-s] [-t] [-d dump_address | dump_blocks | dump_layout | dump_offsets=#,# | dump_pages] [uri]
      options:
          -d config
              display underlying information during verification
          -s  verify against the specified timestamp
          -t  do not clear txn ids during verification

      The problem is code like this in the implementations of the commands:

      while ((ch = __wt_getopt(progname, argc, argv, "c:")) != EOF)
          switch (ch) {
          case 'c': /* command-line configuration */
              config = __wt_optarg;
              break;
          case '?':
          default:
              return (usage());
          }
      

      Because '?' isn't included in the optstring argument to __wt_getopt(), that function treats it as an illegal argument, displaying the "illegal option" message shown above. The fix is to include ? in the optstring. 

      As an aside, after printing the "illegal option" message, __wt_getopt() returns (int)'?', on the assumption that the caller will interpret ? in a useful way, which is why we also see the usage message.

      Acceptance Criteria (Definition of Done)
      All of the command options to the wt utility should print usage information without an error message if given the -? argument. 

      • Testing
        Create a Python test to verify correct functionality.
      • Documentation update
        As long as we're going through this code, this would be a good opportunity to confirm that the description of all the options on the documentation page matches the code.

            Assignee:
            peter.macko@mongodb.com Peter Macko
            Reporter:
            keith.smith@mongodb.com Keith Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: