Commit Graph

272 Commits

Author SHA1 Message Date
Vidar Holen 989ac32625
Merge pull request #1734 from gabrielelana/braced-regular-for
Parse regular `for` with body in curly braces
2019-11-15 20:59:51 -08:00
Vidar Holen 2bbfd0570d
Merge pull request #1735 from gabrielelana/quoted-heredoc
Support for heredoc quoted token like `'"FOO"`
2019-11-15 20:27:10 -08:00
Vidar Holen f44624a9c0 Hide <> from Writer to not conflict with Semigroup 2019-11-14 20:02:25 -08:00
Vidar Holen c75bbcbd60 Include missing Semigroup import 2019-11-13 22:10:27 -08:00
Vidar Holen 4a63a3a8bd For SC2256, make sure the complete string is a variable name 2019-11-13 21:48:01 -08:00
Benjamin Gordon 2341a4c683 SC2256: Check for translated strings matching known variables
SC2247 already warns about translated strings that look like $"(foo)" or
$"{foo}".  Since typical use of translated strings is to translate whole
messages, a string like $"foo" is likely to be a similar mistake if foo
is the name of an existing variable.  Conversely, a string like
$"foo bar" is potentially meant to be a message id even if foo is a
known variable.

Add a warning for the $"foo" case, but make it separate from the
existing warning so that projects that reuse variable names as their
message ids can separately disable the new warning.
2019-11-13 16:41:16 -07:00
Vidar Holen 93eca1cb8e Only trigger SC1014 when command is a complete word (fixes #1737) 2019-11-03 13:26:23 -08:00
Vidar Holen e701cf6fad Warn about [ x -ot y ] in POSIX mode 2019-11-03 13:25:35 -08:00
Vidar Holen 5962b01816 Correctly handle empty variables for SC2086 (fixes #1722) 2019-11-03 12:46:25 -08:00
gabriele.lana 699aac589a Support for heredoc quoted token like `'"FOO"`
Fixes #1650
2019-10-26 17:36:32 +02:00
gabriele.lana 30c75340e6 Parse regular `for` with body in curly braces
Fixes #1694
2019-10-26 15:41:46 +02:00
Vidar Holen 4dfd7eb1cf Use single quotes for the format string example in SC2059 2019-10-24 10:33:17 -07:00
Vidar Holen 60f75e5b8a Warn about unexpected characters after ]/]] (fixes #1680) 2019-10-13 20:26:40 -07:00
Vidar Holen f042b0ebd1 Merge branch 'iboss-ptk-read-t-0' 2019-10-12 20:55:32 -07:00
Vidar Holen 764fdcb260 Move failing test to correct check 2019-10-12 20:50:55 -07:00
Vidar Holen 7473d4a743 Make `read -t 0` test more forgiving towards other flags 2019-10-12 20:45:36 -07:00
Vidar Holen 91abd979f2 Merge branch 'read-t-0' of https://github.com/iboss-ptk/shellcheck into iboss-ptk-read-t-0 2019-10-12 20:23:13 -07:00
Vidar Holen afea62de4e Suggest using `$((..))` in `[ 2*3 -eq 6 ]` (fixes #1641) 2019-10-12 19:55:20 -07:00
Supanat Pothivarakorn 7fb399528c Allow `read -t 0` to not require -r flag
since it has specific purpose for checking only
2019-10-02 22:34:43 +07:00
Vidar Holen de9ab4e6ef Fix glob range duplicate warning in [!!] (fixes #1706) 2019-09-28 14:03:11 -07:00
Vidar Holen e01c470598 Suggest quoting case patterns, as for SC2053 (fixes #1682) 2019-09-08 20:08:43 -07:00
Vidar Holen c175971bf0 Make `-f diff` stop saying it found more issues when it didn't. 2019-07-28 20:50:50 -07:00
Vidar Holen 38bb156a1c Warn about $_ in POSIX sh (fixes #1647) 2019-07-21 21:22:16 -07:00
Vidar Holen 023ae5dfda Don't warn about printf '%()T' without corresponding argument 2019-07-20 15:10:41 -07:00
Vidar Holen 788cf17076 Fix bad advice for SC2251 (fixes #1588) 2019-07-04 19:10:14 -07:00
Vidar Holen 78b8e76066 Also mention globbing in SC2206 (fixes #1626) 2019-07-04 17:43:18 -07:00
Vidar Holen 914974bd4f Don't consider `.*` a glob-like regex (fixes #1214) 2019-07-04 17:41:23 -07:00
Vidar Holen c0d3a98fcd Add warning for chmod -r (fixes #1321) 2019-07-04 16:54:42 -07:00
Vidar Holen 380221a02c Recognize `read -ra foo` as arrays (fixes #1636) 2019-07-03 20:40:41 -07:00
Vidar Holen ba2c20a08a Improve message for SC1067 2019-07-03 20:02:14 -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 bee4303c32 Add an empty Custom.hs to simplify site-specific patching 2019-07-02 20:07:05 -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
Vidar Holen 561075ea79 Merge branch 'shflags' of https://github.com/yetamrra/shellcheck into yetamrra-shflags 2019-07-01 20:00:28 -07:00
Vidar Holen 9702f1ff9c Handle diffs for files without trailing linefeed 2019-06-30 20:19:10 -07:00
Vidar Holen 544047c5af Warn about ending double quotes just to make $ literal 2019-06-30 18:43:42 -07:00
Vidar Holen 321afa427e Remove unused parse-time AST warnings 2019-06-30 17:38:17 -07:00
Vidar Holen c381c5746f Remove unnecessary lookahead in readDollarLonely 2019-06-30 17:28:15 -07:00
Vidar Holen eeb7ea01c9 Allow SC2103 to be silenced (fixes #1591) 2019-06-30 16:36:45 -07:00
Vidar Holen 3116ed3ae5 Filter warnings by annotations in unit tests 2019-06-30 16:36:03 -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
Vidar Holen c5aa171a5f Use mappend over <> for compatibility 2019-06-24 09:02:35 -07:00
Vidar Holen b1aeee564c Add a Diff output format 2019-06-23 20:02:01 -07:00
Vidar Holen e099625e7d Remove unused ioref 2019-06-23 15:50:48 -07:00
Vidar Holen 5242e384a1 Fix error spans for shebang warnings (fixes #1620) 2019-06-23 13:49:08 -07:00
Vidar Holen 7e77bfae49 Improve message for SC2055 2019-06-23 13:48:43 -07:00
Vidar Holen 9059024de6
Merge pull request #1592 from hugopeixoto/fix/SC2016-false-positive
SC2016: Don't trigger when using empty backticks
2019-06-19 19:55:34 -07:00
Vidar Holen 61d2112e71 Add missing JSON1.hs 2019-06-02 13:00:38 -07:00
Vidar Holen 9f0ef5983a Optionally check for unassigned uppercase variables 2019-06-02 10:29:04 -07:00