]> Cypherpunks repositories - gostls13.git/commitdiff
6ar: exit with error status if files cannot be opened.
authorRuss Cox <rsc@golang.org>
Fri, 26 Sep 2008 17:13:57 +0000 (10:13 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 26 Sep 2008 17:13:57 +0000 (10:13 -0700)
R=r
DELTA=15  (8 added, 0 deleted, 7 changed)
OCL=15952
CL=15954

src/cmd/ar/ar.c

index e7024414ce9940dfe054b5531817d8f500a7db9f..1dcfe3233d06e8d6ce179581f6b31e57b19268b5 100644 (file)
@@ -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))