From b3fed0516bfb0c57ce9adf9d51cd3dac46e1c5f9 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 23 Jan 2015 15:32:35 -0500 Subject: [PATCH] grepid: allow arbitrary grep flags and/or multiple search locations --- grepid | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grepid b/grepid index cdd2e4e..f69e152 100755 --- a/grepid +++ b/grepid @@ -18,7 +18,7 @@ COLORS = { using_color = sys.stdout.isatty() def usage(prog_name): - sys.stdout.write('Usage: %s [location]\n' % prog_name) + sys.stdout.write('Usage: %s [grep flags/location...]\n' % prog_name) def ansi_color(out, fg=None, bg=None, bold=False): if using_color: @@ -54,15 +54,15 @@ def main(argv): if len(argv) < 2: usage(argv[0]) return 1 - where = '.' + flags = ['.'] ident = argv[1] - if len(argv) == 3: - where = argv[2] + if len(argv) >= 3: + flags = argv[2:] try: process = Popen(['grep', '--exclude-dir=.svn', '--exclude-dir=.git', '--exclude=tags', - '--color=never', '-HIRn', '\<%s\>' % ident, where], stdout=PIPE) + '--color=never', '-HIRn', '\<%s\>' % ident] + flags, stdout=PIPE) last_file_name = '' lines = []