[PATCH 3/3] mesg: new --verbose option

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

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 term-utils/mesg.1 |    3 +++
 term-utils/mesg.c |   13 +++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/term-utils/mesg.1 b/term-utils/mesg.1
index 5c698c2..811aa18 100644
--- a/term-utils/mesg.1
+++ b/term-utils/mesg.1
@@ -71,6 +71,9 @@ Permits messages to be displayed.
 .TP
 Available options:
 .TP
+.B \-v, \-\-verbose
+Explain what is being done.
+.TP
 .B \-V, \-\-verbose
 Output version information and exit.
 .TP
diff --git a/term-utils/mesg.c b/term-utils/mesg.c
index 33f1941..c77c539 100644
--- a/term-utils/mesg.c
+++ b/term-utils/mesg.c
@@ -69,6 +69,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
 		       " %s [options] [y | n]\n"), program_invocation_short_name);
 	fprintf(out,
 		_("\nOptions:\n"
+		  "  -v, --verbose      explain what is being done\n"
 		  "  -V, --version      output version information and exit\n"
 		  "  -h, --help         output help screen and exit\n"));
 
@@ -79,20 +80,24 @@ int main(int argc, char *argv[])
 {
 	struct stat sb;
 	char *tty;
-	int ch;
+	int ch, verbose = FALSE;
 
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
 
 	static const struct option longopts[] = {
+		{ "verbose",    no_argument,       0, 'v' },
 		{ "version",    no_argument,       0, 'V' },
 		{ "help",       no_argument,       0, 'h' },
 		{ NULL,         0, 0, 0 }
 	};
 
-	while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
+	while ((ch = getopt_long(argc, argv, "vVh", longopts, NULL)) != -1)
 		switch (ch) {
+		case 'v':
+			verbose = TRUE;
+			break;
 		case 'V':
 			printf(_("%s from %s\n"), program_invocation_short_name,
 			PACKAGE_STRING);
@@ -129,10 +134,14 @@ int main(int argc, char *argv[])
 		if (chmod(tty, sb.st_mode | S_IWGRP | S_IWOTH) < 0)
 #endif
 			err(MESG_EXIT_FAILURE, _("change %s mode failed"), tty);
+		if (verbose)
+			puts(_("write access to your terminal is allowed"));
 		return IS_ALLOWED;
 	case 'n':
 		if (chmod(tty, sb.st_mode & ~(S_IWGRP|S_IWOTH)) < 0)
 			 err(MESG_EXIT_FAILURE, _("change %s mode failed"), tty);
+		if (verbose)
+			puts(_("write access to your terminal is denied"));
 		return IS_NOT_ALLOWED;
 	default:
 		warnx(_("invalid argument: %c"), *argv[0]);
-- 
1.7.4.4

--
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