Commit graph

82 commits

Author SHA1 Message Date
Vidar Holen
8d99926554 Recognize local -x similarly to export (fixes #2069) 2020-10-18 15:15:31 -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
1ac2c31728 Warn when shell functions blatantly recurse (fixes #1994) 2020-07-27 21:50:33 -07:00
Vidar Holen
5d753212fb Improve handling of command prefixes like exec/command (fixes #2008) 2020-07-25 13:45:05 -07:00
Joseph C. Sible
999b7e2596 Get rid of bracedString everywhere it's easy to 2020-04-11 19:24:11 -04:00
Vidar Holen
1eac0d7340
Merge pull request #1900 from josephcsible/analyzerlib
Clean up AnalyzerLib
2020-04-11 16:21:20 -07:00
Joseph C. Sible
d22e0aa4a7 Simplify process
Note to self: This is a lot like foldr or traverse, and would be trivial to
implement as such if it didn't need to peek ahead when takesArg is true. I
wonder if there's a clean way to implement it in terms of one of them anyway.
2020-04-05 16:45:45 -04:00
Joseph C. Sible
fb55072302 Implement supportsArrays with pattern-matching 2020-04-05 16:30:59 -04:00
Joseph C. Sible
0cc5ed4563 Don't bother with asks if you're just immediately binding the result anyway 2020-04-05 16:25:43 -04:00
Joseph C. Sible
ca41440a67 Simplify getSpecial 2020-04-05 16:21:07 -04:00
Joseph C. Sible
1cf0aa25e9 Simplify dropPrefix 2020-04-05 16:19:18 -04:00
Joseph C. Sible
4604066c37 Use head instead of (!! 0) 2020-04-05 16:16:12 -04:00
Joseph C. Sible
2ebf522a52 Simplify isArrayFlag 2020-04-05 16:13:55 -04:00
Joseph C. Sible
e4eb2d157f Remove an unnecessary operator section 2020-04-05 16:13:55 -04:00
Joseph C. Sible
f109f9ab92 Remove unnecessary as-patterns 2020-04-05 16:13:55 -04:00
Joseph C. Sible
67e091674e Remove unnecessary maybeToList
The functions we use here are polymorphic enough to work in the [] monad,
so there's no point to use them in the Maybe monad and then convert.
2020-04-05 16:13:54 -04:00
Joseph C. Sible
f833ee3d5a Use a list comprehension instead of a concatMap with extra lists 2020-04-05 15:54:12 -04:00
Joseph C. Sible
f55d8c45e5 Simplify causesSubshell 2020-04-05 15:54:12 -04:00
Joseph C. Sible
14ee462ccd Use execState instead of reimplementing it 2020-04-05 15:50:42 -04:00
Joseph C. Sible
b3c04ce3d0 Implement findFirst in terms of foldr 2020-04-05 15:50:42 -04:00
Joseph C. Sible
b0dbc79f69 Remove unnecessary Maybe from isQuoteFreeElement 2020-04-05 15:07:36 -04:00
Joseph C. Sible
2a8170ba05 Use force instead of reimplementing it 2020-04-05 15:01:57 -04:00
Joseph C. Sible
d2fa88dd91 Simplify nameExpansion 2020-04-05 14:04:23 -04:00
girst
7a5e261d03 recognize : ${parameter=word} as assignment 2020-03-16 23:04:54 +01:00
Joseph C. Sible
45a67e7c64
Use headOrDefault instead of fromMaybe and listToMaybe 2020-03-10 13:27:52 -04:00
Vidar Holen
4c9210af79 Inspect 'alias' commands for referenced variables (Fixes #1832) 2020-02-17 14:20:21 -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
Joseph C. Sible
6d06103cab Remove unnecessary uses of head 2020-02-09 23:18:09 -05:00
Joseph C. Sible
c95914f9b3 Simplify determineShell 2020-02-09 23:18:09 -05:00
Joseph C. Sible
a223a7a5a5 Remove unnecessary fromMaybes 2020-02-09 23:18:08 -05:00
Joseph C. Sible
7e6a556ef1 Get rid of potentially
This already exists as sequence_.
2020-02-09 23:17:52 -05:00
Joseph C. Sible
4d92a2e15c Add getLiteralStringDef and simplify with it 2020-02-09 21:36:38 -05:00
Joseph C. Sible
aaffe38198 Use the Identity monad to avoid unnecessary uses of fromJust 2020-02-08 23:20:54 -05:00
Joseph C. Sible
c29b6afa56 Use null instead of comparing with empty lists 2020-02-01 23:04:04 -05:00
Joseph C. Sible
28978a8b65 Use maybe instead of fromMaybe and fmap 2020-02-01 22:50:17 -05:00
Joseph C. Sible
93be86f988 Use "drop 1" instead of clumsily rewriting it 2020-02-01 22:50:14 -05:00
Joseph C. Sible
3449e6be21 Get rid of our getOpt, as it already exists as lookup 2020-02-01 22:50:13 -05:00
Peter Gromov
a82e606e8d Don't trigger SC2154 (unassigned var) in -n/-z expressions #1583 2020-01-31 14:49:25 +01:00
Gandalf-
fdd02c94c0 Issue 1759 mapfile and process substition
https://github.com/koalaman/shellcheck/issues/1759

When a simple process substition is used, this tripped up
the getMapfileArray function by making the last argument
not a variable
2019-12-22 23:19:03 -08:00
Tito Sacchi
0e0de94045 Fix issue #1724
(bash: missing support for 'builtin' keyword)
Now shellcheck looks for the arguments to 'builtin' to determine
read/written variables. A change in the parser makes sure that
assignments are parsed correctly in commands that start with 'builtin'.
2019-11-01 13:49:17 +01:00
Vidar Holen
7473d4a743 Make read -t 0 test more forgiving towards other flags 2019-10-12 20:45:36 -07:00
Vidar Holen
914974bd4f Don't consider .* a glob-like regex (fixes #1214) 2019-07-04 17:41:23 -07:00
Vidar Holen
380221a02c Recognize read -ra foo as arrays (fixes #1636) 2019-07-03 20:40:41 -07:00
Vidar Holen
be1f1c1ab7 Don't count 'readonly x' as a reference to x (fixes #1573) 2019-07-02 20:58:08 -07:00
Vidar Holen
ef764b60ca Fix botched variable usage 2019-07-01 23:47:13 -07:00
Vidar Holen
3e3e4fd0cd Avoid defining flags for non-literal parameters 2019-07-01 23:22:09 -07:00
Benjamin Gordon
f6ba500d6b Add support for basic shflags semantics
The shflags command-line flags library creates variables at runtime
with a few well-defined functions.  This causes shellcheck to spit out
lots of warnings about unassigned variables, as well as miss warnings
about unused flag variables.

We can address this with two parts:

1. Pretend that the shflags global variables are predefined like other
   shell variables so that shellcheck doesn't expect users to set them.
2. Treat DEFINE_string, DEFINE_int, etc. as new commands that create
   variables, similar to the existing read, local, mapfile, etc.

Part 1 can theoretically be addresssed without this by following sourced
files, but that doesn't help if people are otherwise not following
external sources.

The new behavior is on by default, similar to automatic bats test
behavior.

Addresses #1597
2019-06-25 12:14:54 -06:00