[PATCH 2/7] column.c: add version printing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch makes return value to be non-zero when command line
short option is unknown.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/column.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/text-utils/column.c b/text-utils/column.c
index d8c715d..03679a8 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -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;
-- 
1.7.5

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux