Commit Graph

19 Commits

Author SHA1 Message Date
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 f77a545282 Control Flow Graph / Data Flow Analysis support 2022-07-20 08:08:24 -07:00
Christian Nassif-Haynes 093df8cb24 Add extra checks for masked return codes 2021-10-02 01:36:40 +10:00
Vidar Holen db4701d8b5 Add a `setgitversion` script to update the version string with git 2021-09-18 20:46:46 -07:00
Joseph C. Sible 0f48bb78a5 Remove incorrect otherwise
You're supposed to use otherwise where you need a Boolean, not a pattern
match. This is misleadingly shadowing the real otherwise. Use _ instead.
2020-02-01 22:50:14 -05:00
Vidar Holen 7473d4a743 Make `read -t 0` test more forgiving towards other flags 2019-10-12 20:45:36 -07:00
Vidar Holen afea62de4e Suggest using `$((..))` in `[ 2*3 -eq 6 ]` (fixes #1641) 2019-10-12 19:55:20 -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
Benjamin Gordon 64c9c83cc8 SC2250: New optional check for braces around variable references
Always using braces makes it harder to accidentally change a variable by
pasting other text next to it, but the warning is off by default because
it's definitely a style preference.  Omit special and positional
variables from the check because appending additional characters to them
already doesn't change parsing.
2019-05-14 11:01:38 -06:00
Benjamin Gordon 0358090b3c Refactor definition of special variables.
This ensures that the parser and other places that refer to special
variables can use the same list.
2019-05-14 08:57:56 -06:00
Vidar Holen b76c0a8221 SC2248: Warn about unquoted variables without special chars 2019-04-13 20:19:13 -07:00
Vidar Holen f187382a0c Add bats support
This is motivated by the fact that the popularity of bats is increasing
since the creation of bats-core/bats-core.

The code is a cherry-pick of koalaman/shellcheck/bats branch.

Fix koalaman/shellcheck#417.
2019-01-20 14:59:37 +01:00
Vidar Holen f7b82658f4 Add $# to list of variables not containing spaces (fixes #1362) 2018-10-17 09:00:52 -07:00
Vidar Holen 7ec2fa2d3e Remove 'nice' from list of non-reading commands (fixes #1169) 2018-04-28 11:39:42 -07:00
Oleg Grenrus cd7c077ecc Move library into src/ 2018-03-08 19:57:40 +02:00