aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/mesg.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/init/mesg.c b/init/mesg.c
index ca230f363..2e8b16e5d 100644
--- a/init/mesg.c
+++ b/init/mesg.c
@@ -16,21 +16,23 @@
16#endif 16#endif
17 17
18int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 18int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
19int mesg_main(int argc, char **argv) 19int mesg_main(int argc UNUSED_PARAM, char **argv)
20{ 20{
21 struct stat sb; 21 struct stat sb;
22 const char *tty; 22 const char *tty;
23 char c = 0; 23 char c = 0;
24 24
25 if (--argc == 0 25 argv++;
26 || (argc == 1 && ((c = **++argv) == 'y' || c == 'n')) 26
27 if (!argv[0]
28 || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n'))
27 ) { 29 ) {
28 tty = xmalloc_ttyname(STDERR_FILENO); 30 tty = xmalloc_ttyname(STDERR_FILENO);
29 if (tty == NULL) { 31 if (tty == NULL) {
30 tty = "ttyname"; 32 tty = "ttyname";
31 } else if (stat(tty, &sb) == 0) { 33 } else if (stat(tty, &sb) == 0) {
32 mode_t m; 34 mode_t m;
33 if (argc == 0) { 35 if (c == 0) {
34 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); 36 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
35 return EXIT_SUCCESS; 37 return EXIT_SUCCESS;
36 } 38 }