diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-04-19 23:58:00 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-04-19 23:58:00 +0000 |
commit | 9a8a89647a9e0da8bba19e41c0981ddc84eb8187 (patch) | |
tree | 4e45febc1e60bb431e422cb54792c7db82c099ff | |
parent | c63138122852627ab1508bf97af204601edc4f3f (diff) | |
download | FreeBSD-src-9a8a89647a9e0da8bba19e41c0981ddc84eb8187.zip FreeBSD-src-9a8a89647a9e0da8bba19e41c0981ddc84eb8187.tar.gz |
In the case where we can't open /dev/tty, fall back to -t behaviour.
Submitted by: fenner
-rw-r--r-- | usr.bin/xargs/xargs.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 06a9adf..1ec7766 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -392,15 +392,13 @@ run(char **argv) (void)fprintf(stderr, "%s", *argv); for (p = argv + 1; *p; ++p) (void)fprintf(stderr, " %s", *p); - if (pflag) { - if ((ttyfp = fopen("/dev/tty", "r")) != NULL) { - (void)fprintf(stderr, "?"); - (void)fflush(stderr); - ch = getc(ttyfp); - fclose(ttyfp); - if (ch != 'y') - return; - } + if (pflag && (ttyfp = fopen("/dev/tty", "r")) != NULL) { + (void)fprintf(stderr, "?"); + (void)fflush(stderr); + ch = getc(ttyfp); + fclose(ttyfp); + if (ch != 'y') + return; } else { (void)fprintf(stderr, "\n"); (void)fflush(stderr); |