svn commit: trunk/busybox/findutils

vodz at busybox.net vodz at busybox.net
Fri Sep 23 13:23:19 UTC 2005


Author: vodz
Date: 2005-09-23 06:23:15 -0700 (Fri, 23 Sep 2005)
New Revision: 11591

Log:
grep must have exit code >1 if input file not found. Small indent correcion also.

Modified:
   trunk/busybox/findutils/grep.c


Changeset:
Modified: trunk/busybox/findutils/grep.c
===================================================================
--- trunk/busybox/findutils/grep.c	2005-09-23 11:25:29 UTC (rev 11590)
+++ trunk/busybox/findutils/grep.c	2005-09-23 13:23:15 UTC (rev 11591)
@@ -260,6 +260,7 @@
 	int matched;
 	unsigned long opt;
 	llist_t *fopt = NULL;
+	int error_open_count = 0;
 
 	/* do normal option parsing */
 #ifdef CONFIG_FEATURE_GREP_CONTEXT
@@ -375,6 +376,7 @@
 			if (file == NULL) {
 				if (!suppress_err_msgs)
 					bb_perror_msg("%s", cur_file);
+			error_open_count++;
 		} else {
 			matched += grep_file(file);
 			if(matched < 0) {
@@ -382,9 +384,9 @@
 				* return success */
 				break;
 			}
-				fclose(file);
-			}
+			fclose(file);
 		}
+	}
 
 #ifdef CONFIG_FEATURE_CLEAN_UP
 	/* destroy all the elments in the pattern list */
@@ -396,5 +398,7 @@
 	}
 #endif
 
+	if(error_open_count)
+		return 2;
 	return !matched; /* invert return value 0 = success, 1 = failed */
 }




More information about the busybox-cvs mailing list