]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: check that stdin is a terminal
authorKarel Zak <kzak@redhat.com>
Mon, 2 Dec 2013 12:42:01 +0000 (13:42 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 2 Dec 2013 12:42:01 +0000 (13:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/script.c

index 1de0c3a81662b82f4836e58eb60e7a674409fd5f..c18274c1c2631ae5ce179d55024f53e17d2450ef 100644 (file)
@@ -229,6 +229,10 @@ main(int argc, char **argv) {
                fname = DEFAULT_OUTPUT;
                die_if_link(fname);
        }
+
+       if (!isatty(STDIN_FILENO))
+               errx(EXIT_FAILURE, _("The stdin is not a terminal."));
+
        if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL) {
                warn(_("cannot open %s"), fname);
                fail();