From 27eb5dbc70b25610263960b3236bbe553e7b7cc0 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 5 Jul 2005 21:41:37 +0000 Subject: [PATCH] * cygcheck.cc (track_down, cygcheck): Return true on success. (main): Reflect cygcheck failures in exit status. --- winsup/utils/ChangeLog | 9 +++++++-- winsup/utils/cygcheck.cc | 32 ++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index c58d67d67..bba38e9d8 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2005-07-05 Eric Blake + + * cygcheck.cc (track_down, cygcheck): Return true on success. + (main): Reflect cygcheck failures in exit status. + 2005-06-14 Corinna Vinschen * parse_pe.c (exclusion::sort_and_check): Remove crude cast. @@ -153,9 +158,9 @@ 2004-11-13 Pierre Humblet - * kill.cc (forcekill): Do not pass negative pids to + * kill.cc (forcekill): Do not pass negative pids to cygwin_internal. Check if sig == 0. Improve error messages. - (main): Make pid a long long and distinguish between pids, gpids + (main): Make pid a long long and distinguish between pids, gpids (i.e. negative pids) and Win9x pids. 2004-11-11 Bas van Gompel diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc index 264fd50e1..ba1ee6f37 100644 --- a/winsup/utils/cygcheck.cc +++ b/winsup/utils/cygcheck.cc @@ -364,7 +364,7 @@ struct ImpDirectory }; -static void track_down (char *file, char *suffix, int lvl); +static bool track_down (char *file, char *suffix, int lvl); #define CYGPREFIX (sizeof ("%%% Cygwin ") - 1) static void @@ -554,26 +554,27 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse) cygwin_info (fh); } -static void +// Return true on success, false if error printed +static bool track_down (char *file, char *suffix, int lvl) { if (file == NULL) { display_error ("track_down: NULL passed for file", true, false); - return; + return false; } if (suffix == NULL) { display_error ("track_down: NULL passed for suffix", false, false); - return; + return false; } char *path = find_on_path (file, suffix, 0, 1); if (!path) { printf ("Error: could not find %s\n", file); - return; + return false; } Did *d = already_did (file); @@ -589,7 +590,7 @@ track_down (char *file, char *suffix, int lvl) printf ("%s", path); printf (" (recursive)\n"); } - return; + return true; case DID_INACTIVE: if (verbose) { @@ -598,7 +599,7 @@ track_down (char *file, char *suffix, int lvl) printf ("%s", path); printf (" (already done)\n"); } - return; + return true; default: break; } @@ -609,7 +610,7 @@ track_down (char *file, char *suffix, int lvl) if (!path) { printf ("%s not found\n", file); - return; + return false; } printf ("%s", path); @@ -620,7 +621,7 @@ track_down (char *file, char *suffix, int lvl) if (fh == INVALID_HANDLE_VALUE) { printf (" - Cannot open\n"); - return; + return false; } d->state = DID_ACTIVE; @@ -629,6 +630,7 @@ track_down (char *file, char *suffix, int lvl) d->state = DID_INACTIVE; if (!CloseHandle (fh)) display_error ("track_down: CloseHandle()"); + return true; } static void @@ -653,14 +655,15 @@ ls (char *f) display_error ("ls: CloseHandle()"); } -static void +// Return true on success, false if error printed +static bool cygcheck (char *app) { char *papp = find_on_path (app, (char *) ".exe", 1, 0); if (!papp) { printf ("Error: could not find %s\n", app); - return; + return false; } char *s = strdup (papp); char *sl = 0, *t; @@ -675,7 +678,7 @@ cygcheck (char *app) paths[0] = s; } did = 0; - track_down (papp, (char *) ".exe", 0); + return track_down (papp, (char *) ".exe", 0); } @@ -1590,6 +1593,7 @@ int main (int argc, char **argv) { int i; + bool ok = true; load_cygwin (argc, argv); (void) putenv("POSIXLY_CORRECT=1"); @@ -1677,7 +1681,7 @@ main (int argc, char **argv) { if (i) puts (""); - cygcheck (argv[i]); + ok &= cygcheck (argv[i]); } if (sysinfo) @@ -1693,5 +1697,5 @@ main (int argc, char **argv) puts ("Use -h to see help about each section"); } - return 0; + return ok ? EXIT_SUCCESS : EXIT_FAILURE; }