summaryrefslogtreecommitdiff
path: root/usr.bin/cmp
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1994-08-20 11:14:07 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1994-08-20 11:14:07 +0000
commite5266259990cf891c7b687ea225a34abe355bb9c (patch)
treeeb4fd9ed44cb30a757af7a4854e9e12af7d66686 /usr.bin/cmp
parent1e32938f176164dd6ae3ee6df02e3d896ed995c7 (diff)
Notes
Diffstat (limited to 'usr.bin/cmp')
-rw-r--r--usr.bin/cmp/cmp.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index dc6c64e8be85..29fcb492016b 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;
}