Commit Graph

725 Commits

Author SHA1 Message Date
Joseph C. Sible 10afe83ce3 Use getLiteralStringDef instead of rebuilding it with fromJust 2023-12-31 16:23:45 -05:00
Joseph C. Sible a786f996a1 Replace !!! with pattern-matching where it's easy 2023-12-31 15:55:06 -05:00
Joseph C. Sible 6e5b5401c6 Manually fuse elem and map in checkArrayValueUsedAsIndex 2023-12-31 02:31:07 -05:00
Joseph C. Sible 71c0fcb737 Manually fuse elem and map in isParentOf 2023-12-31 02:27:52 -05:00
Joseph C. Sible add49cda17 Make getPath return a NonEmpty 2023-12-31 02:12:58 -05:00
Joseph C. Sible e1ad063834 Implement getPath in terms of unfoldr 2023-12-31 01:59:53 -05:00
Joseph C. Sible 980e7d3ca8 Use <$> instead of >>= and return 2023-12-30 14:49:26 -05:00
Joseph C. Sible dedf932fe8 Use traverse instead of sequence and map 2023-12-30 13:59:15 -05:00
Joseph C. Sible 3bd7df955b Use a pattern match instead of null and head in checkCommand 2023-12-29 14:18:42 -05:00
Joseph C. Sible f983d9ae93 Simplify functionMap and remove unnecessary partiality 2023-12-21 13:35:22 -05:00
Joseph C. Sible bfe4342697 Remove unnecessary partiality from check 2023-12-19 02:30:48 -05:00
Joseph C. Sible a47a42cb45 Remove unnecessary partiality from isAssignmentParamToCommand 2023-12-19 02:17:59 -05:00
Joseph C. Sible eed0174e90 Make "Unresolved scope in dependency" impossible 2023-12-19 02:06:45 -05:00
Joseph C. Sible 0c46b8b2d5 Use NonEmpty to remove partiality from handleCommand 2023-12-19 01:49:04 -05:00
Joseph C. Sible 208e38358e Use a list comprehension to remove partiality from notesForContext 2023-12-19 01:00:20 -05:00
Joseph C. Sible c1452e0d17 Remove unnecessary partiality from kludgeAwayQuotes 2023-12-19 00:53:08 -05:00
Joseph C. Sible c97abdb939 Make HereDocPending only hold the relevant pieces of a T_HereDoc instead of an arbitrary Token 2023-12-19 00:41:12 -05:00
Joseph C. Sible f242922a2e Use onlyLiteralString in more places 2023-12-19 00:00:32 -05:00
Joseph C. Sible a37803d2b8 Remove partial head function from src/ShellCheck/Formatter/CheckStyle.hs 2023-12-18 23:57:47 -05:00
Joseph C. Sible 5a961371a7 Remove partial head function from src/ShellCheck/Formatter/GCC.hs 2023-12-11 15:55:29 -05:00
Joseph C. Sible e5208ccb50 Remove partial head function from src/ShellCheck/Formatter/JSON1.hs 2023-12-11 15:43:35 -05:00
Joseph C. Sible 4c1d9171b2 Remove partial head function from src/ShellCheck/Formatter/TTY.hs 2023-12-11 15:08:39 -05:00
Vidar Holen a9e7bf1950 Reparse indices after attaching here docs (fixes #2846) 2023-12-10 19:13:34 -08:00
Vidar Holen f2729f73cb Abuse STRIP to avoid crashes on unsupported AST nodes 2023-12-10 17:58:47 -08:00
Vidar Holen 74282b0a93 Recognize 'busybox' in --shell and directives. Add to doc texts. 2023-12-10 17:05:29 -08:00
Grische fdcce458c1 silence some shell expansions for busybox sh 2023-11-27 13:03:29 +01:00
Grische ca255fe326 silence SC3046 and SC3051 for busybox sh 2023-11-27 13:03:17 +01:00
Grische a3b8be82fe silence SC3048 for busybox sh 2023-11-27 13:03:07 +01:00
Grische ac63dc33c9 silence SC3020 for busybox sh 2023-11-27 13:02:56 +01:00
Grische 903421fb5d silence SC3014 for busybox sh 2023-11-27 13:02:45 +01:00
Grische 00ffd2db33 silence SC3010 for busybox sh 2023-11-27 13:02:28 +01:00
Grische 1e1045e73e make busybox sh Dash-like 2023-11-27 13:01:22 +01:00
Grische be8e4b2b8a add basic busybox sh support 2023-11-27 13:00:10 +01:00
Vidar Holen a71a13c2fc
Merge pull request #2837 from ulidtko/fix/missed-test(1)-bashisms
Fix: extend []-related bashism checks on `test` calls too
2023-11-08 13:06:26 -08:00
Joseph C. Sible 1aeab287e6 Add nil case that went missing in 4fd0615 2023-11-03 01:33:49 -04:00
Joseph C. Sible 2a95bc6be3 Switch to getLiteralStringDef to avoid an unnecessary fromJust 2023-10-16 20:00:31 -04:00
Joseph C. Sible 4fd0615501 Stop using head in isLeadingNumberVar 2023-10-16 00:55:04 -04:00
Joseph C. Sible 8b3c37aa36 Use find instead of listToMaybe and filter 2023-10-16 00:06:53 -04:00
Max Ulidtko c89ec2fd49
Fix: do []-related bashism checks on test(1) calls too 2023-10-01 19:57:19 +02:00
Vidar Holen 90d3172dfe Add a newSystemInterface to go with the rest of the new* constructors 2023-08-13 16:35:28 -07:00
Vidar Holen d18b2553cf
Merge pull request #2808 from bruce-ricard/pr/dfbr
improve short description for SC2038
2023-08-13 14:53:15 -07:00
Vidar Holen dd747b2a98 SC2325/SC2326: Warn about ! ! foo and foo | ! bar (fixes #2810) 2023-07-30 19:18:27 -07:00
Vidar Holen 9490b94886 Save and restore pending here docs when sourcing files (fixes #2803) 2023-07-30 16:52:40 -07:00
Vidar Holen 372c0b667e SC2324: Warn when x+=1 appends. 2023-07-30 15:00:43 -07:00
Danny Faught 01aee1a859 improve short description
* The short description used to say that until commit
  aac7d76047 from 2014. It appears that
  it was changed by mistake in that commit to something less readable.

* With the message "use -print0/-0" we were confused and introduced a
  bug in our code because we didn't understand what to do with the
  "-0".

* SC2011 (source
  c9e27c2470/src/ShellCheck/Analytics.hs (L591))
  uses that exact warning message, we copied it from there.

Signed-off-by: Bruce Ricard <bricard@vmware.com>
2023-07-28 14:19:54 -04:00
Joseph C. Sible f03c437e2f Get rid of a dangerous partial function from checkSpacefulnessCfg' 2023-05-24 16:38:53 -04:00
Vidar Holen a54965dd2c Merge branch 'ArenM-posix-read' 2023-04-30 14:49:36 -07:00
Vidar Holen 46b678fca8 Minor fixes to POSIX read without variable check 2023-04-30 14:49:10 -07:00
James Morris 5fec3f9b34 Add fish to the badShells list 2023-04-24 22:08:22 -04:00
Vidar Holen c05380d518 Count CFEExit as control flow for the purposes of finding dominators 2023-02-04 14:47:40 -08:00
Vidar Holen 8c5fdc3522 Update copyright years 2022-12-12 21:49:19 -08:00
Vidar Holen 8754c21244 Avoid $ trigger TH 2022-12-11 19:22:06 -08:00
Vidar Holen 3cae6cd6ab Allow building on deepseq < 1.4.2.0 2022-12-11 15:06:24 -08:00
Vidar Holen 74b1745a19 Fix compiler error on some GHC versions
Fixes the following error:

    src/ShellCheck/CFGAnalysis.hs:1394:40: error:
	* Couldn't match expected type `[S.Set a]'
		      with actual type `M.Map String FunctionValue'
	* In the second argument of `($)', namely
	    `mapStorage $ sFunctionTargets state'
	  In the expression: S.unions $ mapStorage $ sFunctionTargets state
	  In an equation for `declaredFuncs':
	      declaredFuncs = S.unions $ mapStorage $ sFunctionTargets state
	* Relevant bindings include
	    declaredFuncs :: S.Set a
	      (bound at src/ShellCheck/CFGAnalysis.hs:1394:13)
2022-12-11 15:06:24 -08:00
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