]> granicus.if.org Git - graphviz/commitdiff
more portable exit status from nop
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 17:56:34 +0000 (10:56 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Jun 2021 00:01:14 +0000 (17:01 -0700)
The exit status of nop was a bitwise-OR of two error counts. I do not see how
the actual value of this could ever be useful, except for being non-zero.
However, a non-zero exit status is not always an error. E.g. on VMS there are
some non-zero exit statuses that still indicate success.

This change causes nop to more reliably and portably exit with EXIT_FAILURE when
encountering errors.

CHANGELOG.md
cmd/tools/nop.1
cmd/tools/nop.c

index f729bcd06a8ec700c11f7f815b60a711e28d1100..850666ca85eb50ce28a8debdf00b559c6c35061d 100644 (file)
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - marginally more accurate computations in Smyrna sphere projection
 - Perl is no longer required to build Graphviz #2067
+- nop more reliably returns success and failure exit statuses
 
 ### Fixed
 
index 288974c4e9d5ca3ac810f4e9fa7a067f2f6f9ec7..447ea3f94b778351959fce1dced5e9ae0f00f3da 100644 (file)
@@ -25,7 +25,7 @@ Produce no output - just check the input for valid DOT.
 Print usage information.
 .SH "EXIT STATUS"
 If any errors occurred while processing any input, such as a file
-not found or a file containing illegal DOT, a non-zero exit value
-is returned. Otherwise, zero is returned.
+not found or a file containing illegal DOT, \fBEXIT_FAILURE\fR is returned.
+Otherwise \fBEXIT_SUCCESS\fR is returned.
 .SH "SEE ALSO"
 wc(1), acyclic(1), gvpr(1), gvcolor(1), ccomps(1), sccmap(1), tred(1), libgraph(3)
index 1c3cee97ceec203b0f5cf5d5f9ed874b346bc51a..92f2f45416cfc162198e9772deba3029e3f0725c 100644 (file)
@@ -46,11 +46,11 @@ static void init(int argc, char *argv[])
            break;
        case '?':
            if (optopt == '\0' || optopt == '?')
-               usage(0);
+               usage(EXIT_SUCCESS);
            else {
                fprintf(stderr, "nop: option -%c unrecognized\n",
                        optopt);
-               usage(1);
+               usage(EXIT_FAILURE);
            }
            break;
        default:
@@ -83,5 +83,5 @@ int main(int argc, char **argv)
        agclose(g);
     }
 
-    return(ig.errors | agerrors());
+    return (ig.errors != 0 || agerrors() != 0) ? EXIT_FAILURE : EXIT_SUCCESS;
 }