From 8d90df1d7ea3de06e98a3f71d2c519038223a99f Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 30 Apr 2007 16:17:30 +0000 Subject: [PATCH] ebl add -s option to bregtest to be compatible with sed git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4668 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/tools/bregtest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bacula/src/tools/bregtest.c b/bacula/src/tools/bregtest.c index edf7604e7d..b2785de4a3 100644 --- a/bacula/src/tools/bregtest.c +++ b/bacula/src/tools/bregtest.c @@ -50,9 +50,10 @@ static void usage() { fprintf(stderr, "\n" -"Usage: bregex [-d debug_level] -f -e /test/test2/\n" +"Usage: bregtest [-d debug_level] [-s] -f -e /test/test2/\n" " -f specify file of data to be matched\n" " -e specify expression\n" +" -s sed output\n" " -? print this message.\n" "\n"); @@ -65,6 +66,7 @@ int main(int argc, char *const *argv) char *fname = NULL; char *expr = NULL; int ch; + bool sed=false; char data[1000]; FILE *fd; @@ -72,7 +74,7 @@ int main(int argc, char *const *argv) bindtextdomain("bacula", LOCALEDIR); textdomain("bacula"); - while ((ch = getopt(argc, argv, "d:f:e:")) != -1) { + while ((ch = getopt(argc, argv, "sd:f:e:")) != -1) { switch (ch) { case 'd': /* set debug level */ debug_level = atoi(optarg); @@ -89,6 +91,10 @@ int main(int argc, char *const *argv) expr = optarg; break; + case 's': + sed=true; + break; + case '?': default: usage(); @@ -129,7 +135,11 @@ int main(int argc, char *const *argv) while (fgets(data, sizeof(data)-1, fd)) { strip_trailing_newline(data); apply_bregexps(data, list, &p); - printf("%s => %s\n", data, p); + if (sed) { + printf("%s\n", p); + } else { + printf("%s => %s\n", data, p); + } } fclose(fd); free_bregexps(list); -- 2.39.5