]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column.c: add version printing
authorSami Kerola <kerolasa@iki.fi>
Sun, 1 May 2011 17:09:54 +0000 (19:09 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sun, 1 May 2011 17:09:54 +0000 (19:09 +0200)
The patch makes return value to be non-zero when command line
short option is unknown.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/column.c

index d8c715db2d3a096f71c446e763421263d3a6dfa5..03679a87fcd5d88a5c0d7056937a3e37068bc8b2 100644 (file)
@@ -93,6 +93,7 @@ wchar_t *separator = default_separator;       /* field separator for table option */
 static const struct option longopts[] =
 {
        { "help",       0, 0, 'h' },
+       { "version",    0, 0, 'V' },
        { "columns",    0, 0, 'c' },
        { "table",      0, 0, 't' },
        { "separator",  0, 0, 's' },
@@ -110,6 +111,7 @@ static void __attribute__((__noreturn__)) usage(int rc)
 
        fprintf(out, _(
        " -h, --help               displays this help text\n"
+       " -V, --version            output version information and exit\n"
        " -c, --columns <width>    width of output in number of characters\n"
        " -t, --table              create a table\n"
        " -s, --separator <string> table delimeter\n"
@@ -137,12 +139,15 @@ main(int argc, char **argv)
                termwidth = win.ws_col;
 
        tflag = xflag = 0;
-       while ((ch = getopt_long(argc, argv, "h?c:s:tx", longopts, NULL)) != -1)
+       while ((ch = getopt_long(argc, argv, "hVc:s:tx", longopts, NULL)) != -1)
                switch(ch) {
                case 'h':
-               case '?':
                        usage(EXIT_SUCCESS);
                        break;
+               case 'V':
+                       printf(_("%s from %s\n"), program_invocation_short_name,
+                                PACKAGE_STRING);
+                                return(EXIT_SUCCESS);
                case 'c':
                        termwidth = atoi(optarg);
                        break;