Commit a0e79372 authored by Russ Cox's avatar Russ Cox

6ar: exit with error status if files cannot be opened.

R=r
DELTA=15  (8 added, 0 deleted, 7 changed)
OCL=15952
CL=15954
parent 6270e70b
...@@ -121,6 +121,8 @@ int oflag; ...@@ -121,6 +121,8 @@ int oflag;
int uflag; int uflag;
int vflag; int vflag;
int errors;
Arfile *astart, *amiddle, *aend; /* Temp file control block pointers */ Arfile *astart, *amiddle, *aend; /* Temp file control block pointers */
int allobj = 1; /* set when all members are object files of the same type */ int allobj = 1; /* set when all members are object files of the same type */
int symdefsize; /* size of symdef file */ int symdefsize; /* size of symdef file */
...@@ -246,6 +248,8 @@ main(int argc, char *argv[]) ...@@ -246,6 +248,8 @@ main(int argc, char *argv[])
} }
argv++; argv++;
} }
if (errors)
cp = "error";
exits(cp); exits(cp);
} }
/* /*
...@@ -307,8 +311,10 @@ rcmd(char *arname, int count, char **files) ...@@ -307,8 +311,10 @@ rcmd(char *arname, int count, char **files)
} }
bfile = Bopen(file, OREAD); bfile = Bopen(file, OREAD);
if (!bfile) { if (!bfile) {
if (count != 0) if (count != 0) {
fprint(2, "ar: cannot open %s\n", file); fprint(2, "ar: cannot open %s\n", file);
errors++;
}
scanobj(&bar, ap, bp->size); scanobj(&bar, ap, bp->size);
arcopy(&bar, ap, bp); arcopy(&bar, ap, bp);
continue; continue;
...@@ -339,9 +345,10 @@ rcmd(char *arname, int count, char **files) ...@@ -339,9 +345,10 @@ rcmd(char *arname, int count, char **files)
continue; continue;
files[i] = 0; files[i] = 0;
bfile = Bopen(file, OREAD); bfile = Bopen(file, OREAD);
if (!bfile) if (!bfile) {
fprint(2, "ar: %s cannot open\n", file); fprint(2, "ar: cannot open %s\n", file);
else { errors++;
} else {
mesg('a', file); mesg('a', file);
d = dirfstat(Bfildes(bfile)); d = dirfstat(Bfildes(bfile));
if (d == nil) if (d == nil)
...@@ -553,9 +560,10 @@ qcmd(char *arname, int count, char **files) ...@@ -553,9 +560,10 @@ qcmd(char *arname, int count, char **files)
file = files[i]; file = files[i];
files[i] = 0; files[i] = 0;
bfile = Bopen(file, OREAD); bfile = Bopen(file, OREAD);
if(!bfile) if(!bfile) {
fprint(2, "ar: %s cannot open\n", file); fprint(2, "ar: cannot open %s\n", file);
else { errors++;
} else {
mesg('q', file); mesg('q', file);
armove(bfile, 0, bp); armove(bfile, 0, bp);
if (!arwrite(fd, bp)) if (!arwrite(fd, bp))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment