From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 04/17] mesg: use rpmatch to yes/no question
Date: Mon, 5 Mar 2012 20:38:41 +0100 [thread overview]
Message-ID: <1330976334-10751-5-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1330976334-10751-1-git-send-email-kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
term-utils/mesg.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/term-utils/mesg.c b/term-utils/mesg.c
index 13d4fb7..4fad6f5 100644
--- a/term-utils/mesg.c
+++ b/term-utils/mesg.c
@@ -66,6 +66,8 @@
static void __attribute__ ((__noreturn__)) usage(FILE * out)
{
fputs(_("\nUsage:\n"), out);
+ /* TRANSLATORS: this program uses for y and n rpmatch(3),
+ * which means they can be translated. */
fprintf(out,
_(" %s [options] [y | n]\n"), program_invocation_short_name);
@@ -127,8 +129,8 @@ int main(int argc, char *argv[])
return IS_NOT_ALLOWED;
}
- switch (*argv[0]) {
- case 'y':
+ switch (rpmatch(argv[0])) {
+ case 1:
#ifdef USE_TTY_GROUP
if (chmod(tty, sb.st_mode | S_IWGRP) < 0)
#else
@@ -138,14 +140,16 @@ int main(int argc, char *argv[])
if (verbose)
puts(_("write access to your terminal is allowed"));
return IS_ALLOWED;
- case 'n':
+ case 0:
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]);
+ case -1:
+ warnx(_("invalid argument: %s"), argv[0]);
usage(stderr);
+ default:
+ abort();
}
}
--
1.7.9.2
next prev parent reply other threads:[~2012-03-05 19:39 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-04 13:35 [pull] fixes to todo items etc Sami Kerola
2012-03-05 12:38 ` Karel Zak
2012-03-05 19:38 ` Sami Kerola
2012-03-05 19:38 ` [PATCH 01/17] docs: add deprecation comments Sami Kerola
2012-03-05 19:38 ` [PATCH 02/17] docs: TODO removal, login-utils error printing Sami Kerola
2012-03-05 19:38 ` [PATCH 03/17] sfdisk: use rpmatch to yes/no question Sami Kerola
2012-03-05 19:38 ` Sami Kerola [this message]
2012-03-05 19:38 ` [PATCH 05/17] vipw: " Sami Kerola
2012-03-05 19:38 ` [PATCH 06/17] docs: TODO removal, rpmatch task is done Sami Kerola
2012-03-05 19:38 ` [PATCH 07/17] chfn: use pathnames.h for paths Sami Kerola
2012-03-05 19:38 ` [PATCH 08/17] chsh: " Sami Kerola
2012-03-05 19:38 ` [PATCH 09/17] lib: add fileutils function collection Sami Kerola
[not found] ` <"1 330984305.2953.25.camel"@offbook>
[not found] ` <"1330984305.2953.25.camel"@offbook>
2012-03-05 21:51 ` Davidlohr Bueso
2012-03-09 7:56 ` Sami Kerola
2012-03-09 11:48 ` Davidlohr Bueso
2012-03-09 12:20 ` Karel Zak
2012-03-10 11:49 ` Sami Kerola
2012-03-05 19:38 ` [PATCH 10/17] wall: use xmkstemp for temporary file Sami Kerola
2012-03-05 19:38 ` [PATCH 11/17] setpwnam: use xmkstemp() and lckpwdf() Sami Kerola
2012-03-05 19:38 ` [PATCH 12/17] vipw: " Sami Kerola
2012-03-05 19:38 ` [PATCH 13/17] pathnames: clean up various user database paths Sami Kerola
2012-03-05 20:44 ` Sami Kerola
2012-03-05 19:38 ` [PATCH 14/17] docs: TODO removal, ldattach usage is done Sami Kerola
2012-03-05 19:38 ` [PATCH 15/17] include: add asprintf wrapper Sami Kerola
2012-03-05 19:52 ` Dave Reisner
2012-03-05 20:47 ` Sami Kerola
2012-03-05 19:38 ` [PATCH 16/17] xalloc: use xasprintf in all files Sami Kerola
2012-03-05 19:38 ` [PATCH 17/17] build-sys: fix chkdupexe regression Sami Kerola
2012-03-20 8:07 ` [pull] fixes to todo items etc Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330976334-10751-5-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox