Created SC2196 (markdown)

koalaman
2016-12-30 17:10:16 -08:00
parent be08db0c0e
commit 54da57c3c1

26
SC2196.md Normal file

@@ -0,0 +1,26 @@
## egrep is non-standard and deprecated. Use grep -E instead.
### Problematic code:
```sh
egrep 'foo|bar' file
```
### Correct code:
```sh
grep -E 'foo|bar' file
```
### Rationale:
`egrep` is a non-standard command. Its functionality is provided in POSIX by `grep -E`. [POSIX grep](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) says:
>This grep has been enhanced in an upwards-compatible way to provide the exact functionality of the historical egrep and fgrep commands as well. It was the clear intention of the standard developers to consolidate the three greps into a single command.
man grep for GNU says:
>Direct invocation as either egrep or fgrep is deprecated
### Exceptions:
ShellCheck will fail to recognize when functions override `egrep`. Consider giving it a different name or [[ignore]] this error.