From 7fb399528cb9189b29dc92110fab76fcf5d81886 Mon Sep 17 00:00:00 2001 From: Supanat Pothivarakorn Date: Wed, 2 Oct 2019 22:34:43 +0700 Subject: [PATCH] Allow `read -t 0` to not require -r flag since it has specific purpose for checking only --- src/ShellCheck/Analytics.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 5e0adf7..9876679 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -2786,8 +2786,11 @@ checkMaskedReturns _ _ = return () prop_checkReadWithoutR1 = verify checkReadWithoutR "read -a foo" prop_checkReadWithoutR2 = verifyNot checkReadWithoutR "read -ar foo" +prop_checkReadWithoutR3 = verifyNot checkReadWithoutR "read -t 0" +prop_checkReadWithoutR4 = verifyNot checkReadWithoutR "read -t 0 && read --d '' -r bar" +prop_checkReadWithoutR5 = verify checkReadWithoutR "read -t 0 foo < file.txt" checkReadWithoutR _ t@T_SimpleCommand {} | t `isUnqualifiedCommand` "read" = - unless ("r" `elem` map snd (getAllFlags t)) $ + unless (oversimplify t == ["read", "-t", "0"] || "r" `elem` map snd (getAllFlags t)) $ info (getId $ getCommandTokenOrThis t) 2162 "read without -r will mangle backslashes." checkReadWithoutR _ _ = return ()