Skip to content

Commit

Permalink
Rollup merge of #102092 - kxxt:patch-1, r=joshtriplett
Browse files Browse the repository at this point in the history
refactor: use grep -E/-F instead of fgrep/egrep

`egrep` and `fgrep` are obsolescent now. This PR updates  all `egrep` and `fgrep` commands to `grep -E` and `grep -F`.

Running egrep/fgrep command with grep v3.8 will output the following warning to stderr:

```
egrep: warning: egrep is obsolescent; using grep -E
```

- https://www.phoronix.com/news/GNU-Grep-3.8-Stop-egrep-fgrep
- https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html
  • Loading branch information
matthiaskrgr authored Oct 14, 2022
2 parents 5819f41 + 6135aff commit f72d76d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/etc/cat-and-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Options:
-i Case insensitive search.
'

GREPPER=fgrep
GREPPER=grep
INVERT=0
GREPFLAGS='q'
while getopts ':vieh' OPTION; do
Expand All @@ -39,7 +39,7 @@ while getopts ':vieh' OPTION; do
GREPFLAGS="i$GREPFLAGS"
;;
e)
GREPPER=egrep
GREPFLAGS="E$GREPFLAGS"
;;
h)
echo "$USAGE"
Expand All @@ -51,6 +51,12 @@ while getopts ':vieh' OPTION; do
esac
done

if ! echo "$GREPFLAGS" | grep -q E
then
# use F flag if there is not an E flag
GREPFLAGS="F$GREPFLAGS"
fi

shift $((OPTIND - 1))

# use gnu version of tool if available (for bsd)
Expand Down

0 comments on commit f72d76d

Please sign in to comment.