Be POSIXly correct in the handling of /dev/stdout -- it's a "magic cookie"

not a special file.
This commit is contained in:
fanf 2003-02-27 02:24:01 +00:00
parent 3fc9836d46
commit 2e51ade059

View File

@ -226,7 +226,7 @@ decode2(void)
}
q = memcpy(p - n, pw->pw_dir, n);
}
} else {
} else if (strcmp(q, "/dev/stdout") != 0) {
/* strip down to leaf name */
p = strrchr(q, '/');
if (p != NULL)
@ -235,7 +235,8 @@ decode2(void)
if (!oflag)
outfile = q;
if (pflag)
/* POSIX says "/dev/stdout" is a 'magic cookie' not a special file. */
if (pflag || strcmp(outfile, "/dev/stdout") == 0)
outfp = stdout;
else {
flags = O_WRONLY|O_CREAT|O_EXCL;