diff options
author | jkh <jkh@FreeBSD.org> | 1994-08-20 11:14:07 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1994-08-20 11:14:07 +0000 |
commit | 8a342cc41247d4ffbe873cc294bb6e4ff0339933 (patch) | |
tree | eb4fd9ed44cb30a757af7a4854e9e12af7d66686 | |
parent | 6dce261964d8fd9139125215f08d7b63eb98cb5b (diff) | |
download | FreeBSD-src-8a342cc41247d4ffbe873cc294bb6e4ff0339933.zip FreeBSD-src-8a342cc41247d4ffbe873cc294bb6e4ff0339933.tar.gz |
I don't like what they did to cmp(1) in 4.4 Lite; now it whines all
the time, even with -s. Make cmp SHUT UP about non-existant files
when run with -s.
Submitted by: jkh
-rw-r--r-- | usr.bin/cmp/cmp.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c index dc6c64e..29fcb49 100644 --- a/usr.bin/cmp/cmp.c +++ b/usr.bin/cmp/cmp.c @@ -99,8 +99,12 @@ endargs: fd1 = 0; file1 = "stdin"; } - else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) - err(ERR_EXIT, "%s", file1); + else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) { + if (!sflag) + err(ERR_EXIT, "%s", file1); + else + exit(1); + } if (strcmp(file2 = argv[1], "-") == 0) { if (special) errx(ERR_EXIT, @@ -109,20 +113,32 @@ endargs: fd2 = 0; file2 = "stdin"; } - else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) - err(ERR_EXIT, "%s", file2); + else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) { + if (!sflag) + err(ERR_EXIT, "%s", file2); + else + exit(1); + } skip1 = argc > 2 ? strtol(argv[2], NULL, 10) : 0; skip2 = argc == 4 ? strtol(argv[3], NULL, 10) : 0; if (!special) { - if (fstat(fd1, &sb1)) - err(ERR_EXIT, "%s", file1); + if (fstat(fd1, &sb1)) { + if (!sflag) + err(ERR_EXIT, "%s", file1); + else + exit(1); + } if (!S_ISREG(sb1.st_mode)) special = 1; else { - if (fstat(fd2, &sb2)) - err(ERR_EXIT, "%s", file2); + if (fstat(fd2, &sb2)) { + if (!sflag) + err(ERR_EXIT, "%s", file2); + else + exit(1); + } if (!S_ISREG(sb2.st_mode)) special = 1; } |