From ab9dfe4ee3835c3e86565d81a5e3c8526e34a206 Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Sun, 8 Jan 2023 13:25:51 -0800 Subject: [PATCH] Warn when using deprecated rgrep. --- src/ShellCheck/Analytics.hs | 2 +- src/ShellCheck/Checks/Commands.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 1f6d96d60..680c48eee 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -3029,7 +3029,7 @@ checkShouldUseGrepQ params t = T_DollarExpansion _ [x] -> getPipeline x T_Pipeline _ _ cmds -> return cmds _ -> fail "unknown" - isGrep = (`elem` ["grep", "egrep", "fgrep", "zgrep"]) + isGrep = (`elem` ["grep", "egrep", "fgrep", "rgrep", "zgrep"]) prop_checkTestArgumentSplitting1 = verify checkTestArgumentSplitting "[ -e *.mp3 ]" prop_checkTestArgumentSplitting2 = verifyNot checkTestArgumentSplitting "[[ $a == *b* ]]" diff --git a/src/ShellCheck/Checks/Commands.hs b/src/ShellCheck/Checks/Commands.hs index 691836f42..269fc671f 100644 --- a/src/ShellCheck/Checks/Commands.hs +++ b/src/ShellCheck/Checks/Commands.hs @@ -91,6 +91,7 @@ commandChecks = [ ,checkDeprecatedTempfile ,checkDeprecatedEgrep ,checkDeprecatedFgrep + ,checkDeprecatedRgrep ,checkWhileGetoptsCase ,checkCatastrophicRm ,checkLetUsage @@ -988,6 +989,10 @@ prop_checkDeprecatedFgrep = verify checkDeprecatedFgrep "fgrep '*' files" checkDeprecatedFgrep = CommandCheck (Basename "fgrep") $ \t -> info (getId $ getCommandTokenOrThis t) 2197 "fgrep is non-standard and deprecated. Use grep -F instead." +prop_checkDeprecatedRgrep = verify checkDeprecatedRgrep "rgrep '*' dir" +checkDeprecatedRgrep = CommandCheck (Basename "rgrep") $ + \t -> info (getId $ getCommandTokenOrThis t) 2324 "rgrep is non-standard and deprecated. Use grep -r instead." + prop_checkWhileGetoptsCase1 = verify checkWhileGetoptsCase "while getopts 'a:b' x; do case $x in a) foo;; esac; done" prop_checkWhileGetoptsCase2 = verify checkWhileGetoptsCase "while getopts 'a:' x; do case $x in a) foo;; b) bar;; esac; done" prop_checkWhileGetoptsCase3 = verifyNot checkWhileGetoptsCase "while getopts 'a:b' x; do case $x in a) foo;; b) bar;; *) :;esac; done"