We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1de00d1 commit 43bcc71Copy full SHA for 43bcc71
src/etc/cat-and-grep.sh
@@ -26,7 +26,7 @@ Options:
26
-i Case insensitive search.
27
'
28
29
-GREPPER=fgrep
+GREPPER=grep
30
INVERT=0
31
GREPFLAGS='q'
32
while getopts ':vieh' OPTION; do
@@ -39,7 +39,7 @@ while getopts ':vieh' OPTION; do
39
GREPFLAGS="i$GREPFLAGS"
40
;;
41
e)
42
- GREPPER=egrep
+ GREPFLAGS="E$GREPFLAGS"
43
44
h)
45
echo "$USAGE"
@@ -51,6 +51,15 @@ while getopts ':vieh' OPTION; do
51
esac
52
done
53
54
+# an utility function to check if a string contains a substring
55
+stringContain() { [ -z "$1" ] || { [ -z "${2##*$1*}" ] && [ -n "$2" ];};}
56
+
57
+if ! stringContain 'E' "$GREPFLAGS"
58
+then
59
+ # use F flag if there is not an E flag
60
+ GREPFLAGS="F$GREPFLAGS"
61
+fi
62
63
shift $((OPTIND - 1))
64
65
# use gnu version of tool if available (for bsd)
0 commit comments