]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - term-utils/mesg.c
su: change error message
[thirdparty/util-linux.git] / term-utils / mesg.c
index d5a7f2e29989ca4962051ec202489c13bc3115cb..608f3cf61ace1133f93fab3c6daca5ce9cd62ec8 100644 (file)
@@ -80,8 +80,8 @@ static void __attribute__((__noreturn__)) usage(void)
 
        fputs(USAGE_OPTIONS, out);
        fputs(_(" -v, --verbose  explain what is being done\n"), out);
-       print_usage_help_options(16);
-       fprintf(out, USAGE_MAN_TAIL("mesg(1)"));
+       printf(USAGE_HELP_OPTIONS(16));
+       printf(USAGE_MAN_TAIL("mesg(1)"));
 
        exit(EXIT_SUCCESS);
 }
@@ -121,6 +121,11 @@ int main(int argc, char *argv[])
        argc -= optind;
        argv += optind;
 
+       if (!isatty(STDERR_FILENO)) {
+               if (verbose)
+                       warnx(_("no tty"));
+               exit(MESG_EXIT_FAILURE);
+       }
        if ((tty = ttyname(STDERR_FILENO)) == NULL)
                err(MESG_EXIT_FAILURE, _("ttyname failed"));
        if ((fd = open(tty, O_RDONLY)) < 0)