Ignore:
Timestamp:
Oct 6, 2007, 12:16:46 AM (18 years ago)
Author:
bird
Message:

Added --version and --help to all builtins.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/rmdir.c

    r1151 r1183  
    5151#include <unistd.h>
    5252#include "getopt.h"
     53#include "kmkbuiltin.h"
    5354
    5455#ifdef _MSC_VER
     
    5758
    5859static int rm_path(char *);
    59 static int usage(void);
     60static int usage(FILE *);
    6061
    6162static int pflag;
     
    6667static struct option long_options[] =
    6768{
     69    { "help",                       no_argument, 0, 262 },
    6870    { "ignore-fail-on-non-empty",   no_argument, 0, 260 },
    6971    { "ignore-fail-on-not-exist",   no_argument, 0, 261 },
    7072    { "parents",                    no_argument, 0, 'p' },
    7173    { "verbose",                    no_argument, 0, 'v' },
     74    { "version",                    no_argument, 0, 263 },
    7275    { 0, 0,     0, 0 },
    7376};
     
    7578
    7679int
    77 kmk_builtin_rmdir(int argc, char *argv[])
     80kmk_builtin_rmdir(int argc, char *argv[], char **envp)
    7881{
    7982        int ch, errors;
     
    102105                        ignore_fail_on_not_exist = 1;
    103106                        break;
     107                case 262:
     108                        return kbuild_version(argv[0]);
     109                case 263:
     110                        usage(stdout);
     111                        return 0;
    104112                case '?':
    105113                default:
    106                         return usage();
     114                        return usage(stderr);
    107115                }
    108116        argc -= optind;
     
    110118
    111119        if (argc == 0)
    112                 return /*usage()*/0;
     120                return /*usage(stderr)*/0;
    113121
    114122        for (errors = 0; *argv; argv++) {
     
    181189
    182190static int
    183 usage(void)
     191usage(FILE *pf)
    184192{
    185 
    186         (void)fprintf(stderr, "usage: rmdir [-pv --ignore-fail-on-non-empty --ignore-fail-on-not-exist] directory ...\n");
     193        (void)fprintf(pf, "usage: %s [-pv --ignore-fail-on-non-empty --ignore-fail-on-not-exist] directory ...\n"
     194                          "   or: %s --help\n"
     195                          "   or: %s --version\n",
     196                      g_progname, g_progname, g_progname);
    187197        return 1;
    188198}
Note: See TracChangeset for help on using the changeset viewer.