From: Russ Cox Date: Fri, 26 Sep 2008 17:13:57 +0000 (-0700) Subject: 6ar: exit with error status if files cannot be opened. X-Git-Tag: weekly.2009-11-06~3114 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a0e7937243336af37f19f093b011b825f37037a4;p=gostls13.git 6ar: exit with error status if files cannot be opened. R=r DELTA=15 (8 added, 0 deleted, 7 changed) OCL=15952 CL=15954 --- diff --git a/src/cmd/ar/ar.c b/src/cmd/ar/ar.c index e7024414ce..1dcfe3233d 100644 --- a/src/cmd/ar/ar.c +++ b/src/cmd/ar/ar.c @@ -121,6 +121,8 @@ int oflag; int uflag; int vflag; +int errors; + Arfile *astart, *amiddle, *aend; /* Temp file control block pointers */ int allobj = 1; /* set when all members are object files of the same type */ int symdefsize; /* size of symdef file */ @@ -246,6 +248,8 @@ main(int argc, char *argv[]) } argv++; } + if (errors) + cp = "error"; exits(cp); } /* @@ -307,8 +311,10 @@ rcmd(char *arname, int count, char **files) } bfile = Bopen(file, OREAD); if (!bfile) { - if (count != 0) + if (count != 0) { fprint(2, "ar: cannot open %s\n", file); + errors++; + } scanobj(&bar, ap, bp->size); arcopy(&bar, ap, bp); continue; @@ -339,9 +345,10 @@ rcmd(char *arname, int count, char **files) continue; files[i] = 0; bfile = Bopen(file, OREAD); - if (!bfile) - fprint(2, "ar: %s cannot open\n", file); - else { + if (!bfile) { + fprint(2, "ar: cannot open %s\n", file); + errors++; + } else { mesg('a', file); d = dirfstat(Bfildes(bfile)); if (d == nil) @@ -553,9 +560,10 @@ qcmd(char *arname, int count, char **files) file = files[i]; files[i] = 0; bfile = Bopen(file, OREAD); - if(!bfile) - fprint(2, "ar: %s cannot open\n", file); - else { + if(!bfile) { + fprint(2, "ar: cannot open %s\n", file); + errors++; + } else { mesg('q', file); armove(bfile, 0, bp); if (!arwrite(fd, bp))