Commit Graph

297 Commits

Author SHA1 Message Date
Vidar Holen b044f5b23a Don't trigger SC2140 on ${x+"a" "b"} (fixes #2265) 2021-09-18 18:59:42 -07:00
Vidar Holen 8012f6761d Suppress SC2094 when both are input redirections (fixes #2325) 2021-09-18 18:00:15 -07:00
Vidar Holen 9a54e91195
Merge pull request #2318 from FabianWolff/grep-lL-wc-l
Do not suggest `grep -c` as a replacement for `grep -l/-L | wc -l`
2021-09-16 19:40:40 -07:00
Vidar Holen 64733cc110
Merge pull request #2303 from DoxasticFox/set-e-functions
Show info about `set -e` suppression during function calls
2021-09-04 17:06:24 -04:00
Christian Nassif-Haynes dc9032fca5 Show info about `set -e` suppression during function calls 2021-09-05 04:23:25 +10:00
Fabian Wolff 40216487d6 Do not suggest `grep -c` as a replacement for `grep -l/-L | wc -l` 2021-09-02 17:47:06 +02:00
Vidar Holen 747bd8fd6a Warn about strings for numerical operators in [[ ]] (fixes #2312) 2021-08-30 19:50:00 -07:00
Vidar Holen f5fd9c2fed Improve warnings about unnecessary subshells (fixes #2169) 2021-08-30 10:56:55 -07:00
Vidar Holen 081f7eba24 Fix parsing of [$var] (fixes #2309) 2021-08-26 23:05:14 -07:00
Vidar Holen 81b7ee5598 Don't warn about unused variables starting with _ (fixes #1498) 2021-08-26 19:40:21 -07:00
Vidar Holen c85ce2cb06 Add `rg` to list of commands ignored for SC2016 (fixes #2209) 2021-08-26 18:50:40 -07:00
Vidar Holen da7b28213e Recognize wait -p as assigning a variable (fixes #2179) 2021-08-17 21:53:27 -07:00
Vidar Holen c61fc7546e Don't warn about variables guarded with :+ (fixes #2296) 2021-08-17 16:20:32 -07:00
Vidar Holen 8c0bf8d41f Warn about looping over array values and using them as keys 2021-08-17 12:51:27 -07:00
Vidar Holen bb0a571a1e Improve warnings for bad parameter expansion (fixes #2297) 2021-08-16 21:02:20 -07:00
Vidar Holen fed4a048bc Suppress SC2167 when name is "_" (fixes #2298) 2021-08-13 23:11:20 -07:00
Vidar Holen cf8066c07c SC2295 Warn about unquoted variables in PE patterns (fixes #2290) 2021-08-03 13:02:53 -07:00
Vidar Holen e33146d530 Avoid trigger SC2181 on composite $? checks (fixes #1167) 2021-07-29 20:51:19 -07:00
Vidar Holen fe81dc1c27 Optionally suggest [[ over [ in Bash scripts (-o require-double-brackets) (fixes #887) 2021-07-27 18:53:30 -07:00
Vidar Holen fbc8d2cb2f Don't consider [ -n/-z/-v $var ] assignments for subshell modification (fixes #2217) 2021-07-27 09:33:22 -07:00
Vidar Holen c471e45822 Allow printf/return/assignments after exec (fixes #2249) 2021-07-26 19:32:33 -07:00
Vidar Holen 4956b006ac Fix broken test from previous commit 2021-07-25 19:56:51 -07:00
Vidar Holen 02e07625d1 Warn about quoting in assignments to sh declaration utilities (fixes #1556) 2021-07-25 19:36:42 -07:00
Vidar Holen 44471b73cc Have SC2155 trigger on 'typeset' as well (fixes #2262) 2021-07-25 17:34:14 -07:00
Vidar Holen 0d58337cdd Don't warn about repeated range in [[ -v arr[xxx] ]] (fixes #2285) 2021-07-25 13:01:57 -07:00
Vidar Holen 99f6554c9b SC2181: Add '!' in suggestion as appropriate (fixes #2189) 2021-07-18 16:59:45 -07:00
Vidar Holen 022bc8277c
Merge pull request #2238 from bcran/legacy-backticks-msg
Fix typo in SC2006 message: "backticked" vs "backticks"
2021-07-02 09:55:18 -07:00
Vidar Holen 163b2f12e2 Sanity check command names (fixes #2227) 2021-06-05 18:16:22 -07:00
Rebecca Cran b61a7658d6 Fix typo in SC2006 message: "backticked" vs "backticks" 2021-05-24 13:33:50 -06:00
Vidar Holen 331e89be99 Fix bad warning for ${#arr[*]}. Fixes #2218. 2021-04-26 10:44:33 -07:00
Vidar Holen fe25a2b00e Treat ${arr[*]} like $* for SC2048 2021-04-24 17:08:10 -07:00
Vidar Holen 9e60b3ea84 Fix haddock failures (fixes #2216) 2021-04-22 22:17:51 -07:00
Vidar Holen 5669eb2203 Make x-comparison warning default 2021-04-11 15:52:13 -07:00
Vidar Holen f02c297fdd Merge parser and analyzer shebang parsing 2021-03-11 23:04:17 -08:00
Vidar Holen ea83b602d7 Merge branch 'busybox' of https://github.com/austin987/shellcheck into austin987-busybox 2021-03-11 21:44:17 -08:00
Vidar Holen 83435c4f2e
Merge pull request #2134 from kolyshkin/podman-sc2016
Whitelist podman for SC2016 about '$var'
2021-03-07 20:48:58 -08:00
Vidar Holen a69d6cb661
Merge pull request #2117 from brother/patch-1
Change error 2076 to a warning.
2021-03-07 20:47:53 -08:00
Austin English 2e59eba6eb add support for `/bin/busybox sh` shebang 2021-02-05 19:56:44 -06:00
Vidar Holen 15ff87cf80
Merge pull request #2119 from josephcsible/refactors
Various refactorings
2021-02-02 18:14:27 -08:00
Kir Kolyshkin 99e9d5c54b Whitelist podman for SC2016 about '$var'
Same as 08d2eef411 but for podman.

Fixes https://github.com/koalaman/shellcheck/issues/2057

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-27 16:21:44 -08:00
Vidar Holen dff8f9492a Improve SC2283 message and position 2021-01-05 10:07:39 -08:00
Vidar Holen 9584266a8b Escape control characters when adding user data to messages 2020-12-31 12:28:48 -08:00
Vidar Holen fbb14d6b38 Improve checks for = in command names (fixes #2102) 2020-12-30 20:30:43 -08:00
Joseph C. Sible 34939ca0b7 Fuse map into any 2020-12-28 18:13:34 -05:00
Joseph C. Sible 8480563672 Use syntactic sugar instead of building lists by hand 2020-12-28 18:13:34 -05:00
Joseph C. Sible dfbcc9595e Use mapM instead of reimplementing it 2020-12-28 17:48:58 -05:00
Joseph C. Sible 2c0766825e Implement groupByLink in terms of foldr 2020-12-28 17:45:11 -05:00
Joseph C. Sible cb4f4e7edc Use mapM_ instead of reimplementing it 2020-12-28 17:34:52 -05:00
Martin Bagge / brother 19355226e1
Change error 2076 to a warning.
Implementing the suggestion by @pixarbuff #1985.
2020-12-27 00:27:36 +01:00
Vidar Holen bd3299edd3 Treat 'exec $1' like '$1' for the purpose of quoting (fixes #2068) 2020-12-17 20:31:45 -08:00
Vidar Holen cc3884cf9f Support env -S/--split-string in shebangs (fixes #2105) 2020-12-12 20:24:32 -08:00
Vidar Holen 6ba1af0898 Warn when a variable is assigned to itself 2020-12-11 20:28:36 -08:00
Vidar Holen 65044c2568 SC2095: Also warn if the command is backgrounded 2020-11-29 13:01:23 -08:00
Keith Smiley 619662adb6 Add readonly to SC2155
This adds a warning for readonly masking the return value of function.
This is mentioned in the wiki
https://github.com/koalaman/shellcheck/wiki/SC2155#problematic-code-in-the-case-of-readonly
but didn't actually produce a warning.

Fixes https://github.com/koalaman/shellcheck/issues/1336
2020-10-23 17:29:04 -07:00
Vidar Holen 28d3279ba6 Optional style warning about [ x$var = xval ] 2020-10-19 20:04:58 -07:00
Vidar Holen 256457c47a Use getopts parser to find 'read' arrays (fixes #2073) 2020-10-18 22:57:16 -07:00
Vidar Holen f100c2939e Rewrite getopts style option parser 2020-10-18 21:34:58 -07:00
Vidar Holen 8d99926554 Recognize `local -x` similarly to `export` (fixes #2069) 2020-10-18 15:15:31 -07:00
Vidar Holen 218deb6d01 Update SC2091/SC2092 message and ignore in quotes. 2020-09-08 19:30:13 -07:00
Vidar Holen 43191fa71d Suppress SC2035 for echo * and printf * (fixes #2036) 2020-09-01 14:19:28 -07:00
Vidar Holen a62d9f10c2 Warn when using &/| between test statements 2020-08-23 15:43:33 -07:00
Vidar Holen 50067ddf94 Consider variables in -z/-n tests to be checked 2020-08-08 12:32:20 -07:00
Vidar Holen 3fa5b7d3bd Merge branch 'supportMinusNZ' of https://github.com/donnerpeter/shellcheck into donnerpeter-supportMinusNZ 2020-08-08 11:22:00 -07:00
Vidar Holen e779aedac3 Modernize getting mapfile array name 2020-08-07 16:41:18 -07:00
Vidar Holen 3ef1175566 Merge branch 'issue_1759_mapfile_proc_substition' of https://github.com/Gandalf-/shellcheck into Gandalf--issue_1759_mapfile_proc_substition 2020-08-07 15:57:59 -07:00
Vidar Holen 3e50a2fce8 Suppress SC2216 for du --files0-from or --exclude-from (fixes #1286) 2020-08-07 14:59:34 -07:00
Vidar Holen 1ac2c31728 Warn when shell functions blatantly recurse (fixes #1994) 2020-07-27 21:50:33 -07:00
Vidar Holen 34885142e7 Handle tilde expansion in pattern matching (fixes #1769) 2020-07-27 18:34:42 -07:00
Vidar Holen 5d753212fb Improve handling of command prefixes like exec/command (fixes #2008) 2020-07-25 13:45:05 -07:00
Vidar Holen 5cf2c00ff7 Warn about defining and using an alias in a single command (fixes #1807) 2020-05-25 23:24:33 -07:00
Vidar Holen a08ad3bee9 Count $# as an argument reference in SC2120 2020-05-25 23:24:33 -07:00
Vidar Holen d6adbfde78 Improve SC2259/60/61 messages 2020-05-03 21:46:16 -07:00
Vidar Holen 2030b83607 Warn about duplicate uses of stdin/out/err 2020-05-03 11:54:25 -07:00
Vidar Holen 73cc11fd0a
Merge pull request #1901 from josephcsible/bracedstring
Mostly get rid of bracedString
2020-04-12 15:14:50 -07:00
Joseph C. Sible b58bb4ba9d Move bracedString to be local to its last use site 2020-04-11 19:24:11 -04:00
Joseph C. Sible 999b7e2596 Get rid of bracedString everywhere it's easy to 2020-04-11 19:24:11 -04:00
Joseph C. Sible 8a7497c4f0 Simplify checkVariableBraces 2020-04-11 19:23:13 -04:00
Joseph C. Sible 322842b57e Remove unnecessary monadicity from wordToPseudoGlob 2020-04-05 19:29:40 -04:00
Vidar Holen 01f4423465 Disable SC2257 about > $((i=42)) for Dash 2020-04-05 11:38:22 -07:00
Vidar Holen bd717c9d1b Don't warn about [ 0 -ne $FOO ] || [ 0 -ne $BAR ] (fixes #1891) 2020-04-01 22:09:00 -07:00
Vidar Holen da0931740f
Merge pull request #1876 from fork-graveyard/master
recognize `: ${parameter=word}` as assignment
2020-04-01 18:52:53 -07:00
Vidar Holen c60323fb25
Merge pull request #1873 from josephcsible/checkwhilereadpitfalls
Simplify checkWhileReadPitfalls
2020-03-31 19:10:53 -07:00
girst 7a5e261d03 recognize `: ${parameter=word}` as assignment 2020-03-16 23:04:54 +01:00
Joseph C. Sible 9d5363377e Simplify checkWhileReadPitfalls
* Clean up usage of not
* Use a case match instead of sequence_ and a do block
2020-03-16 00:14:22 -04:00
Joseph C. Sible 86d470c74f Simplify checkForInQuoted
* Avoid some unnecessary fmaps
* Reuse an identical pattern-match for two guards
* Apply De Morgan's law
* Use forM_ to avoid an unnecessary where
2020-03-15 16:05:55 -04:00
Vidar Holen a57f6d2886 Improve detection of for loops with single values 2020-03-15 11:30:56 -07:00
Vidar Holen c43b19f897 Make SC2095 (ssh in while read loops) more robust and suggest fixes 2020-03-14 21:15:47 -07:00
Austin English 741d499b3d src/ShellCheck/Analytics.hs: suggest using a shell directive for SC2148 2020-03-07 19:23:35 -06:00
Vidar Holen 7b998239af SC2257: Warn when changing arithmetic variables in redirections 2020-02-17 18:16:57 -08:00
Vidar Holen 4c9210af79 Inspect 'alias' commands for referenced variables (Fixes #1832) 2020-02-17 14:20:21 -08:00
Vidar Holen c2d67c15f8
Merge pull request #1802 from szydell/master
SC2016, repair false error for M language parser
2020-02-10 18:25:28 -08:00
Vidar Holen 6043deb8f2
Merge pull request #1824 from josephcsible/patch-1
Simplify literalEquals
2020-02-10 18:20:05 -08:00
Vidar Holen d0beac6d0b
Merge pull request #1826 from josephcsible/nofromjust
Use the Identity monad to avoid unnecessary uses of fromJust
2020-02-10 18:05:36 -08:00
Vidar Holen b88b253cad
Merge pull request #1827 from josephcsible/nofromjust2
Remove more unnecessary uses of fromJust
2020-02-10 18:01:38 -08:00
Joseph C. Sible 6d06103cab Remove unnecessary uses of head 2020-02-09 23:18:09 -05:00
Joseph C. Sible ea24e25efd Use Map.member instead of isJust and Map.lookup 2020-02-09 23:18:09 -05:00
Joseph C. Sible 8f0448133c Use isNothing instead of reimplementing it 2020-02-09 23:18:08 -05:00
Joseph C. Sible 7fc9496320 Use forM_ instead of reimplementing it 2020-02-09 23:18:08 -05:00
Joseph C. Sible 962fad038c Avoid a zip that breaks fusion 2020-02-09 23:18:08 -05:00
Joseph C. Sible a223a7a5a5 Remove unnecessary fromMaybes 2020-02-09 23:18:08 -05:00