Created attachment 265 [details] new usage patch sacct --usage displays nothing This is a regression. I reported and supplied a patch for this problem last January. The problem is in the options definition for usage. Here is the declaration for usage in git-master {"usage", no_argument, ¶ms.opt_help, OPT_LONG_USAGE}, The comments to _getopt_internal in getopt.c declare that when the flag field for a long-named option (3rd field) is nonzero, it returns 0. In which case, the option is not found in the switch statement. The attached patch fixes the problem. Since the usage routine simply prints Usage: sacct [options] Use --help for help I actually think the following declaration would be better. {"usage", no_argument, 0, 'h'}, This directly invokes help saving the user from doing sacct --help. In this case the usage routine should probably be removed, as well as usage cases in switch statements.
There are some other issues with parsing options for sacct. I will be sending another patch, so don't apply this one as the new one will also include the usage patch.
Created attachment 266 [details] More fixes to sacct options
The additional bug reported to us was that -d (dump) still worked. Actually, it didn't dump, it turned into --allusers. I also found --duplicates had the same problem as --usage as it is a long option and git_master had nonzero in the flags field. So I tried to make the argument to getopt_long consistent using these rules; 1) If there was a letter in getopt_long arg that did not have a case clause in the following switch statement, I removed it. 2) If there was a clause in the switch statement that wasn't in the help message, or the long_options declaration, I removed the case and the letter in the list ('t'). I have to admit I'm not completely comfortable with everything I've done, so please review carefully.
I still think --usage should directly to help.
(In reply to comment #3) > The additional bug reported to us was that -d (dump) still worked. > > Actually, it didn't dump, it turned into --allusers. That is interesting, my guess is since getopt_long was still accepting it funky things were happening. Strange none the less. > > I also found --duplicates had the same problem as --usage as it is a long > option and git_master had nonzero in the flags field. > > So I tried to make the argument to getopt_long consistent using these rules; > > 1) If there was a letter in getopt_long arg that did not have a case clause > in the following switch statement, I removed it. Yeah, it looks like the 'd' and 'O' was dump and formatted-dump. Good catch. 'U' wasn't handled either. > 2) If there was a clause in the switch statement that wasn't in the help > message, or the long_options declaration, I removed the case and the letter > in the list ('t'). This was a deprecated option, while it probably isn't used by anyone I left it and documented what happened. > > I have to admit I'm not completely comfortable with everything I've done, so > please review carefully. I modified the patch slightly (6974ac0b0a44520046ba52b7dbfd05b03d221380). I think everything works now. Let me know if it doesn't. This code was done a long time ago from HP, I am surprised no one has ever complained. I guess people don't use the long options :).