From 54da57c3c177514ab2b245a69bc2a03b5e1f85d5 Mon Sep 17 00:00:00 2001 From: koalaman Date: Fri, 30 Dec 2016 17:10:16 -0800 Subject: [PATCH] Created SC2196 (markdown) --- SC2196.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 SC2196.md diff --git a/SC2196.md b/SC2196.md new file mode 100644 index 0000000..9c9440b --- /dev/null +++ b/SC2196.md @@ -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. \ No newline at end of file