static ino_t inode_num;
#endif
+#ifdef CONFIG_FEATURE_FIND_EXEC
+static char **exec_str;
+static int num_matches;
+static int exec_opt;
+#endif
+
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (pattern != NULL) {
goto no_match;
}
#endif
+#ifdef CONFIG_FEATURE_FIND_EXEC
+ if (exec_opt) {
+ int i;
+ char *cmd_string = "";
+ for (i = 0; i < num_matches; i++)
+ cmd_string = bb_xasprintf("%s%s%s", cmd_string, exec_str[i], fileName);
+ cmd_string = bb_xasprintf("%s%s", cmd_string, exec_str[num_matches]);
+ system(cmd_string);
+ goto no_match;
+ }
+#endif
+
puts(fileName);
no_match:
return (TRUE);
inode_num = strtol(argv[i], &end, 10);
if (end[0] != '\0')
bb_error_msg_and_die(msg_invalid_arg, argv[i], "-inum");
+#endif
+#ifdef CONFIG_FEATURE_FIND_EXEC
+ } else if (strcmp(argv[i], "-exec") == 0) {
+ int b_pos;
+ char *cmd_string = "";
+
+ while (i++) {
+ if (i == argc)
+ bb_error_msg_and_die(msg_req_arg, "-exec");
+ if (*argv[i] == ';')
+ break;
+ cmd_string = bb_xasprintf("%s %s", cmd_string, argv[i]);
+ }
+
+ if (*cmd_string == 0)
+ bb_error_msg_and_die(msg_req_arg, "-exec");
+ cmd_string++;
+ exec_str = xmalloc(sizeof(char *));
+
+ while ((b_pos = strstr(cmd_string, "{}") - cmd_string), (b_pos >= 0)) {
+ num_matches++;
+ exec_str = xrealloc(exec_str, (num_matches + 1) * sizeof(char *));
+ exec_str[num_matches - 1] = bb_xstrndup(cmd_string, b_pos);
+ cmd_string += b_pos + 2;
+ }
+ exec_str[num_matches] = bb_xstrdup(cmd_string);
+ exec_opt = 1;
#endif
} else
bb_show_usage();