From: Jim Meyering Date: Sat, 11 Nov 1995 14:21:15 +0000 (+0000) Subject: (main): Don't die when dev/ino of input and output are X-Git-Tag: TEXTUTILS-1_13F~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24aec7f87ff14a3229d080007a77e1dc7ae79f2b;p=thirdparty%2Fcoreutils.git (main): Don't die when dev/ino of input and output are the same and the file descriptors correspond to stdin and stdout. This is necessary on at least Digital UNIX (aka OSF1) 3.2C. Otherwise, running `cat << X > $$' would fail with `cat: -: input file is output file'. From Jarkko Hietaniemi . --- diff --git a/src/cat.c b/src/cat.c index 77dec0e2e1..0038c19211 100644 --- a/src/cat.c +++ b/src/cat.c @@ -654,7 +654,8 @@ main (int argc, char **argv) files cannot be redirected to themselves. */ if (check_redirection - && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino) + && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino + && (input_desc != fileno (stdin) || output_desc != fileno (stdout))) { error (0, 0, _("%s: input file is output file"), infile); exit_stat = 1;