Radosla Tomaszewski wrote...

> I would like to see what files are ignored when run-parts is running. It can 
> be print 
> with options '--test' or throw the syslog when run-parts is normaly 
> executing. Some 
> mistake with file name will be easy to find.

That would have been helpful to debug #790027, so here's the patch I
applied beforehand. Merge it, boil it, enhance¹ it, or forget it.

And while you're on it, please add an additional line break:

--- a/run-parts.c
+++ b/run-parts.c
@@ -609,7 +609,7 @@ regex_compile_pattern (void)
         pt_regex = &classicalre;
 
     if (err != 0) {
-        fprintf(stderr, "Unable to build regexp: %s", \
+        fprintf(stderr, "Unable to build regexp: %s\n", \
                             regex_get_error(err, pt_regex));
         exit(1);
     }

Cheers,

    Christoph

¹ Should show the result of the stat() checks as well.
commit 4822d05f49950b3e3886f6d2bbd52b7489bb2fb7
Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
Date:   Wed Nov 15 19:12:46 2017 +0100

    run-parts: Print debugging information when checking for a valid file name

diff --git a/run-parts.c b/run-parts.c
index 9a80229..4caa424 100644
--- a/run-parts.c
+++ b/run-parts.c
@@ -38,6 +38,7 @@
 int test_mode = 0;
 int list_mode = 0;
 int verbose_mode = 0;
+int debug_mode = 0;
 int report_mode = 0;
 int reverse_mode = 0;
 int exitstatus = 0;
@@ -91,6 +92,7 @@ void usage()
 	  "      --list          print names of all valid files (can not be used with\n"
 	  "                      --test)\n"
 	  "  -v, --verbose       print script names before running them.\n"
+	  "  -d, --debug         print script names while checking them.\n"
 	  "      --report        print script names if they produce output.\n"
 	  "      --reverse       reverse execution order of scripts.\n"
 	  "      --exit-on-error exit as soon as a script returns with a non-zero exit\n"
@@ -146,19 +148,30 @@ int valid_name(const struct dirent *d)
 
     s = (char *)&(d->d_name);
 
-    if (regex_mode == RUNPARTS_ERE)
+    if (regex_mode == RUNPARTS_ERE) {
         retval = !regexec(&customre, s, 0, NULL, 0);
+	if (debug_mode)
+	    fprintf(stderr, "\"%s\": customre %s\n", s, retval ? "pass" : "fail");
 
-    else if (regex_mode == RUNPARTS_LSBSYSINIT) {
+    } else if (regex_mode == RUNPARTS_LSBSYSINIT) {
 
-        if (!regexec(&hierre, s, 0, NULL, 0))
+        if (!regexec(&hierre, s, 0, NULL, 0)) {
             retval = regexec(&excsre, s, 0, NULL, 0);
+	    if (debug_mode)
+		fprintf(stderr, "\"%s\": hierre pass, excsre %s\n", s, retval ? "pass" : "fail");
 
-	else
+	} else {
             retval = !regexec(&tradre, s, 0, NULL, 0);
+	    if (debug_mode)
+		fprintf(stderr, "\"%s\": tradre %s\n", s, retval ? "pass" : "fail");
 
-    } else
+	}
+    } else {
         retval = !regexec(&classicalre, s, 0, NULL, 0);
+	if (debug_mode)
+	    fprintf(stderr, "\"%s\": classicalre %s\n", s, retval ? "pass" : "fail");
+
+    }
 
     return retval;
 }
@@ -489,6 +502,7 @@ int main(int argc, char *argv[])
       {"test", 0, &test_mode, 1},
       {"list", 0, &list_mode, 1},
       {"verbose", 0, 0, 'v'},
+      {"debug", 0, 0, 'd'},
       {"report", 0, &report_mode, 1},
       {"reverse", 0, &reverse_mode, 1},
       {"umask", 1, 0, 'u'},
@@ -507,7 +521,7 @@ int main(int argc, char *argv[])
       break;
     switch (c) {
     case 0:
-      if(option_index==10) { /* hardcoding this will lead to trouble */
+      if(option_index==11) { /* hardcoding this will lead to trouble */
         custom_ere = strdup(optarg);
       }
       break;
@@ -523,6 +537,9 @@ int main(int argc, char *argv[])
     case 'v':
       verbose_mode = 1;
       break;
+    case 'd':
+      debug_mode = 1;
+      break;
     case 'V':
       version();
       break;

Attachment: signature.asc
Description: Digital signature

Reply via email to