blob: 4f783d9d032ef74480cc7362c4439027fba742b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
# Read grep(1) patterns from input and search for them in the given files
self=rgl
# Check the arguments
if [ "$#" -eq 0 ] ; then
printf >&2 '%s: Need at least one filename\n' "$self"
exit 2
fi
# Iterate over the patterns and search for each one
while {
# If the input is a terminal, print a slash prompt for the next pattern;
# try to print it in bold red, too, but discard stderr if we can't
if [ -t 0 ] ; then
tput setaf 1 || tput AF 1
tput bold || tput md
printf '%s/' "$self"
tput sgr0 || tput me
fi 2>/dev/null
# Read the pattern
IFS= read -r pat
} ; do
# Run grep(1) with the read pattern over the arguments
grep -- "$pat" "$@"
done
|