Vidar Holen
495e34d101
Add missing Semigroup import for older GHC
2022-12-11 14:19:24 -08:00
Vidar Holen
2a16a4e8c1
Add missing imports for later GHC versions
2022-12-10 15:17:08 -08:00
ArenM
3342902d9a
Warn about 'read' without a variable in POSIX sh
...
Dash throws an error if the read command isn't supplied a variable name.
2022-11-17 18:46:15 -05:00
Vidar Holen
0786b2bf3c
Merge pull request #2601 from mavit/colon-after-exec
...
Permit colon after exec
2022-11-02 21:18:56 -07:00
Vidar Holen
86e2b76730
Improve SC1059 error message
2022-10-29 12:50:26 -07:00
Vidar Holen
b770984dfc
Try to parse the inside of traps ( fixes #2584 )
2022-10-13 21:04:38 -07:00
Vidar Holen
d9c9e60fb0
Allow arbitrary bats @test names ( fixes #2587 )
2022-10-13 20:21:59 -07:00
Vidar Holen
14056a7f3a
Don't suggest pgrep for `ps -p .. | grep` ( fixes #2597 )
2022-10-12 20:22:02 -07:00
Vidar Holen
a524929b69
Remove outdated test
2022-10-12 20:22:02 -07:00
Vidar Holen
81c2ecaccb
Remove true/false from SC2216/SC2217 ( fixes #2603 )
2022-10-11 19:40:29 -07:00
Christian Nassif-Haynes
43aca62ca7
Fix false positive for SC2312 when using `time`
2022-10-10 03:33:38 +11:00
Peter Oliver
128351f5ef
Permit colon after exec
...
ShellCheck throws warning SC2093 when a script contains commands that could never be executed because they are after an `exec`. Command `:` does nothing, so add it to the list of commands that don’t trigger this warning.
2022-10-07 17:02:31 +01:00
Vidar Holen
d71d6ff294
Merge pull request #2581 from larryv/updatebashvars
...
Support more Bash internal variables
2022-09-25 11:24:45 -07:00
Vidar Holen
bd65b67578
Merge pull request #2586 from DoxasticFox/issue-2537
...
Suppress SC2311 with `set -o posix`
2022-09-25 11:04:30 -07:00
Christian Nassif-Haynes
ef5f9a7af5
Add `mapfile` to harmless commands for SC2094
2022-09-25 03:04:20 +10:00
Christian Nassif-Haynes
581981ba76
Suppress SC2311 with `set -o posix`
2022-09-24 07:20:48 +10:00
Vidar Holen
fcc473e27f
Include inherited env for DFA of leftover functions ( fixes #2560 )
2022-09-21 18:11:18 -07:00
Lawrence Velázquez
0845b81183
Add READLINE_POINT to list of variables without spaces
2022-09-20 20:39:17 -04:00
Lawrence Velázquez
966fb3e3dd
Recognize more Bash internal variables
...
- BASH_ARGV0, introduced in Bash 5.0
- BASH_COMPAT, 4.3
- BASH_LOADABLES_PATH, 4.4
- CHILD_MAX, 4.3
- EPOCHREALTIME, 5.0
- EPOCHSECONDS, 5.0
- EXECIGNORE, 4.4
- INSIDE_EMACS, 4.4
- PS0, 4.4
- READLINE_ARGUMENT, 5.2
- READLINE_MARK, 5.1
- SRANDOM, 5.1
Fixes #1780 and #2554 .
2022-09-20 20:39:10 -04:00
Lawrence Velázquez
f28462b01c
Remove duplicate "COPROC" from internal vars list
2022-09-20 20:25:21 -04:00
Lawrence Velázquez
ccab132b38
Reflow lists of internal shell variables
...
No functional changes; this just makes the next few commits cleaner.
2022-09-20 20:24:37 -04:00
Vidar Holen
4806719035
Handle variable assignments from `read` in CFG
2022-08-02 15:47:59 -07:00
Vidar Holen
0df9345142
Trace numerical status, use for SC2071 (ref #2541 )
2022-08-02 11:29:56 -07:00
Vidar Holen
77069f7445
Store postdominators as Array Node [Node] for a significant win
2022-07-31 15:43:24 -07:00
Vidar Holen
04db46381f
Use Data.Map.Strict instead for a ~15% parsing speedup
2022-07-29 09:02:45 -07:00
Vidar Holen
c76b8d9a32
Let annotations take effect earlier ( fixes #2534 )
2022-07-28 11:05:16 -07:00
Vidar Holen
d0dd81e1fa
Allow quoting values in directives ( fixes #2517 )
2022-07-28 08:56:44 -07:00
Vidar Holen
f440912279
Refactor to not generate Parameters twice
2022-07-28 08:26:56 -07:00
Vidar Holen
3ce310e939
Plug space leaks when processing multiple files
2022-07-27 14:42:57 -07:00
Vidar Holen
a30ac402eb
Don't use & for updates as result is unspecified
...
This fixes `Prelude.foldl1: empty list []` when script has `( exit )`
2022-07-27 11:30:26 -07:00
Vidar Holen
4a27c9a8d5
Fix overlap check
2022-07-26 15:33:25 -07:00
Vidar Holen
b5f5e6347d
Discard next rather than existing fixes when they overlap
2022-07-26 13:41:22 -07:00
Vidar Holen
c57e447c89
Correctly discard overlapping fixes in diff output ( fixes #2370 )
2022-07-26 10:16:12 -07:00
Vidar Holen
e9784fa9a7
Refine #2544 to not warn when $? postdominates [ ] ( fixes #2544 )
2022-07-25 12:00:59 -07:00
Vidar Holen
f1148b8b41
Include postdominators in CFGResult
2022-07-25 12:00:53 -07:00
Vidar Holen
982681fc05
Add unit test to ensure SC2321 does not trigger on associative arrays
2022-07-24 14:30:31 -07:00
Vidar Holen
52dac51cd4
SC2323: Warn about redundant parens in a[(x+1)] and $(( ((x)) )) (ref: #1666 )
2022-07-24 14:18:38 -07:00
Vidar Holen
30bb0e0093
SC2321: Warn about redundant $(()) in arr[$((i))]=x (ref: #1666 )
2022-07-24 14:18:38 -07:00
Vidar Holen
ea4e0091c7
Additionally pluralize 'arguments' in SC2183
2022-07-23 15:38:42 -07:00
Vidar Holen
81d9f7e640
Merge branch 'grammer_fix_sc2183' of https://github.com/ygeyzel/shellcheck into ygeyzel-grammer_fix_sc2183
2022-07-23 15:34:22 -07:00
Vidar Holen
69469c3603
Merge pull request #2543 from ygeyzel/SC2028-escape-chars
...
Add escape characters to SC2028: \a, \b, \e, \f, \v, \\, \', \OOO, \xHH
2022-07-23 15:30:00 -07:00
Vidar Holen
5cf6e01ce9
Warn when $? refers to echo or condition (ref #2541 )
2022-07-23 09:39:26 -07:00
ygeyzel
f7857028f7
Add escape characters to SC2028: \a, \b, \e, \f, \v, \\, \', \OOO, \xHH
2022-07-23 19:28:37 +03:00
Vidar Holen
b261ec24f9
Include exit codes in DFA (ref #2541 )
2022-07-23 08:50:19 -07:00
Vidar Holen
819470fa1d
Omit SC3021 about `>& file` unless definitely non-numeric ( fixes #2520 )
2022-07-22 17:06:24 -07:00
Vidar Holen
2f28847b08
Normalize spaces around = in unit tests
2022-07-22 16:35:14 -07:00
Vidar Holen
e47480e93a
Also emit SC2004 for array indices ( fixes #1666 )
2022-07-22 16:29:52 -07:00
Vidar Holen
9caeec104b
SC2318: Warn about backreferencing in `declare x=1 y=$x` ( fixes #1653 )
2022-07-22 12:40:59 -07:00
Vidar Holen
95b3cbf071
Qualify Data.Map as M instead of tedious Map
2022-07-22 11:11:09 -07:00
Vidar Holen
e7f05d662a
In addition to start/end, track sets of nodes belonging to tokens
2022-07-22 10:29:19 -07:00
Vidar Holen
3ee4419ef4
Suppress SC2086 for variables declared -i (ref #2541 )
2022-07-22 08:53:27 -07:00
Vidar Holen
da4885a71d
Use DFA for SC2086
2022-07-20 08:08:44 -07:00
Vidar Holen
642ad86125
Add SC2317 warning about unreachable commands
2022-07-20 08:08:41 -07:00
Vidar Holen
f77a545282
Control Flow Graph / Data Flow Analysis support
2022-07-20 08:08:24 -07:00
Vidar Holen
a4042f7523
Parse &&/|| as left-associative
2022-07-20 08:08:24 -07:00
Vidar Holen
363c0633e0
When reparsing array indices, do it recursively
2022-07-20 08:08:24 -07:00
ygeyzel
7ceb1f1519
SC2183 grammer fix: 'variable' instead of 'variables' if only one variable
2022-07-17 21:46:42 +03:00
Vidar Holen
fd595d1058
Only trigger SC2316 on unquoted words.
2022-05-06 10:06:12 -07:00
Rune Juhl Jacobsen
2821552688
Fix bug in 2126 when using after/before flags with grep
...
Using `--after-context`/`-A` or `--before-context`/`-B` would give a warning
recommending the user to use `grep -c`, even though that would give a different
result than using `grep | wc -l`:
```fundamental
$ echo -e "1\n2\n3" | grep -cA 3 1
1
$ echo -e "1\n2\n3" | grep -A 3 1 | wc -l
3
```
2022-05-06 09:17:23 -07:00
Patrick Xia
fa15c0a454
add SC2316: error on multiple declarations like 'readonly local'
2022-05-05 16:19:07 -07:00
Vidar Holen
88cdb4e2c9
Warn about spaces around = in alias ( fixes #2442 )
2022-02-03 19:23:46 -08:00
Vidar Holen
ade2bf7b87
Allow parsing [[ x = ["$y"] ]] ( fixes #2165 )
2022-01-09 16:50:50 -08:00
Vidar Holen
e6e558946c
Improve decoding of single quoted literals ( fixes #2418 )
2021-12-21 14:30:39 -08:00
Vidar Holen
dd626686c4
Merge pull request #2375 from scop/spelling
...
Comment spelling fixes
2021-12-05 14:27:08 -08:00
Vidar Holen
d7971dafd1
Minor formatting fixes
2021-12-04 17:37:12 -08:00
Martin Schulze
9092080a84
bats: Add check for useless negation (SC2314/15)
2021-11-15 12:01:12 +01:00
Vidar Holen
499c99372e
Rewrite SC2032 warning and mention line number ( fixes #2353 )
2021-11-14 21:34:21 -08:00
Vidar Holen
d9a9d5db86
Mark prefix/postfix inc/dec as integers ( fixes #2376 )
2021-11-14 16:39:32 -08:00
Ville Skyttä
c5de58ae84
Comment spelling fixes
2021-11-13 12:50:53 +02:00
Vidar Holen
3b6972fbf1
Update copyright years
2021-11-06 19:07:34 -07:00
Vidar Holen
8db220ae43
Include `local -r` in check-extra-masked-returns ( fixes #2362 )
2021-11-06 15:37:59 -07:00
Vidar Holen
efd49e486f
Consider all forms of TA_Assignment to remove spaces ( fixes #2364 )
2021-10-30 17:47:30 -07:00
Vidar Holen
0dd5c67bdf
Warn about [^..] in Dash ( fixes #2361 )
2021-10-21 21:00:39 -07:00
Vidar Holen
788aee1b7c
Treat typeset similar to declare ( fixes #2354 )
2021-10-15 14:41:48 -07:00
Vidar Holen
c3aaa27540
Skip SC2214 if variable is modified in loop ( fixes #2351 )
2021-10-09 12:13:41 -07:00
Vidar Holen
3aedda766d
For `while getopts; do case ..` checks, make sure variable matches
2021-10-09 11:40:52 -07:00
Vidar Holen
205ba429b3
Warn about `read foo[i]` expanding as glob ( fixes #2345 )
2021-10-07 18:50:44 -07:00
Vidar Holen
38251abe26
Add suggestion level in text for TTY output ( fixes #2339 )
2021-10-07 17:14:41 -07:00
Vidar Holen
23cddb037e
Merge pull request #2320 from DoxasticFox/set-e-proc-sub
...
Add extra checks for masked return codes
2021-10-02 12:52:59 -07:00
Christian Nassif-Haynes
093df8cb24
Add extra checks for masked return codes
2021-10-02 01:36:40 +10:00
Vidar Holen
fac97a5301
Don't emit SC2140 when trapped string is /, = or : ( fixes #2334 )
2021-09-25 20:23:58 -07:00
Vidar Holen
ad92cb4112
Disable UUOC for cat with unquoted variable ( fixes #2333 )
2021-09-25 19:46:27 -07:00
Vidar Holen
db4701d8b5
Add a `setgitversion` script to update the version string with git
2021-09-18 20:46:46 -07:00
Vidar Holen
e7df718724
Strip lines containing "STRIP" from ./striptests
2021-09-18 20:43:42 -07:00
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
2536507060
Remove SC1004 ( fixes #2326 )
2021-09-18 17:43:55 -07:00
Vidar Holen
09aa15c9b7
Allow `disable=all` to disable all warnings ( fixes #2323 )
2021-09-18 12:50:01 -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
4e703e5c61
Allow specifying external-sources=true in shellcheckrc ( fixes #1818 )
2021-09-15 18:02:37 -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
5b6fd60279
Improve warnings for expr ( fixes #2033 )
2021-08-22 21:12:58 -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
e5745568e8
Extend warnings about spaces around = to 'let'
2021-08-08 15:48:50 -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
a44f3edb14
Warn about eval'ing arrays
2021-07-30 18:46:19 -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
754ab22d94
Warn about unquoted blanks in echo ( fixes #377 )
2021-07-26 18:59: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
364c33395e
Don't print colors when $TERM is 'dumb' or unset ( fixes #2260 )
2021-07-25 14:44:35 -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
9eb63c97e6
Re-add warnings about 'declare var = value' ( fixes #2279 )
2021-07-24 13:25:56 -07:00
Vidar Holen
8be60028ef
Don't warn when line starts with &> ( fixes #2281 )
2021-07-22 19:25:48 -07:00
Vidar Holen
9b077e28cb
Add :/. to chars recognized for \alias suppression ( fixes #2287 )
2021-07-21 16:44:21 -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
5e60f1eddb
Merge pull request #2241 from Kamilcuk/master
...
Add a comma to function characters
2021-07-02 09:54:51 -07:00
Vidar Holen
163b2f12e2
Sanity check command names ( fixes #2227 )
2021-06-05 18:16:22 -07:00
Kamil Cukrowski
5100960303
Add a comma to function characters
...
Bash has very relaxed function name rules and a comma is also a valid
character. This commit silences SC1036 check when a function name has a
comma in its name.
2021-05-26 10:58:38 +02: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
Matthias Diener
087865c680
Clarify 'which'
2021-03-20 20:43:18 -05:00
Vidar Holen
98952df35b
Improve warnings on backslashes in comments
2021-03-20 18:12:39 -07:00
Vidar Holen
a277efdbb1
Merge branch 'comment-backslash' of https://github.com/m-ildefons/shellcheck into m-ildefons-comment-backslash
2021-03-20 13:34:40 -07:00
Vidar Holen
ecdc21b0b7
Merge pull request #2112 from pepeiborra/patch-1
...
Add Haddock markup to SystemInterface
2021-03-14 13:16:29 -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
Moritz Röhrich
d6bb8fc0d8
Error on backslash in comment #2132
...
- Report error in case of a backspace in a comment
Backspaces in comments are no good. In most cases they are the result of
commenting out a longer line, that was broken down. This usually results
in the shell treating the following lines as their own commands on their
own lines instead of as parts of the longer, broken down line.
2021-02-14 19:13:29 +01:00
Claudio Bley
8bb5e01401
Allow `env` to have flags and variables in shebang
...
The `env` command has a `-S,--split-string` option which enables
having arguments for the command in a shebang.
Also, one could use variable assignments for the command since
`env` treats only the first word without a `=` character as the
command to run.
Fixes #2143 .
2021-02-12 10:53:54 +01: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
2e5c56b270
Parse heredocs correctly with carriage returns ( fixes #2103 )
2020-12-31 13:19:14 -08:00
Vidar Holen
9584266a8b
Escape control characters when adding user data to messages
2020-12-31 12:28:48 -08:00
Vidar Holen
5fbaae2bb3
Don't treat ${!x@} as reference of x ( fixes #2116 )
2020-12-30 20:55:18 -08:00
Vidar Holen
fbb14d6b38
Improve checks for = in command names ( fixes #2102 )
2020-12-30 20:30:43 -08:00
Joseph C. Sible
2cfd1f2714
Fuse maps
2020-12-28 18:13:34 -05:00
Joseph C. Sible
953d9bc56d
Remove unused helper stub
2020-12-28 18:13:34 -05:00