Commit Graph

355 Commits

Author SHA1 Message Date
Vidar Holen 8ec9fa43fd Warn about break/continue in subshells and outside loops 2014-02-01 23:45:26 -08:00
Vidar Holen e8634a3c27 Removed duplicate check for [[ a == b + 1 ]] 2014-02-01 20:45:44 -08:00
Vidar Holen 9ae776530b Check for [[ i + 1 = 2 ]] 2014-01-27 22:47:48 -08:00
Vidar Holen 82328cd86e Warn about literal "\ " just like literal quotes.
Also, do it recursively.
2014-01-27 22:11:46 -08:00
Vidar Holen 4262c4b1bf Allow {} in arithmetic for loops 2014-01-26 12:44:51 -08:00
Vidar Holen 7ad0110443 Don't warn about sed '$d' or '$p' 2014-01-25 14:54:05 -08:00
Vidar Holen e9bba2f75a Don't warn about comma separation in for f in {a,b} 2014-01-25 14:30:25 -08:00
Vidar Holen 74ea5eaeec Parse but warn about "else if" 2014-01-25 14:12:31 -08:00
Vidar Holen cfb44b3fe2 Warn about 'cd $f; foo; cd ..' loop antipattern. 2014-01-17 09:02:14 -08:00
Vidar Holen 43ed5e748d Allow '# shellcheck disable=SC1234' to ignore by code. 2014-01-16 23:08:56 -08:00
Vidar Holen 4dca88aade Don't warn about quotes in variables for eval 2014-01-16 19:41:09 -08:00
Vidar Holen 1d2c7a8551 Warn about abused char classes, such as [10-15] and [:digit:] 2014-01-14 21:20:21 -08:00
Vidar Holen 659709d529 Fixed ${!var} not counting as reference of var 2013-12-30 10:00:05 -08:00
Vidar Holen 5b4729d940 Parser: allow subshell function definitions 2013-12-30 09:50:14 -08:00
Vidar Holen 8c00850134 Minor performance tweaks (~10% improvement) 2013-12-15 18:43:34 -08:00
Vidar Holen d1990e3396 Warn about 'i=i+1' and 'i=i + 1' 2013-12-15 16:11:17 -08:00
Vidar Holen 95ebe1cd07 Fixed parser error for '..; done| ..' 2013-12-15 14:39:47 -08:00
Vidar Holen 27822a1f56 Warn about 'foo=bar echo $foo' 2013-12-14 16:06:19 -08:00
Vidar Holen eb06b06475 Don't warn about single quoted vars for ssh 2013-12-14 15:28:58 -08:00
Vidar Holen 5d72432046 If printf string contains %, don't warn about using vars 2013-12-14 15:27:11 -08:00
Vidar Holen da51b14789 Parser: accept here doc token strings more liberally 2013-12-14 15:20:15 -08:00
Vidar Holen 7be8485b8b Fixed parsing of 'time' in front of compound commands 2013-12-14 14:44:47 -08:00
Vidar Holen a4d36ba0d2 Warn about while read f; do ssh "$f"; done 2013-11-29 23:05:41 -08:00
Vidar Holen d4bc0f6e10 Don't require separator before do in 'for i do ..' 2013-11-29 16:22:37 -08:00
Vidar Holen 1011ae7b3c Fixed incorrect parsing of [ foo -a -f bar ] 2013-11-24 18:49:49 -08:00
Vidar Holen d603ee1e89 Don't warn for A&&B||C if C is echo/exit/assignment 2013-11-24 16:15:10 -08:00
Vidar Holen 4fc518c877 Cleaned up command matching code 2013-11-24 15:48:07 -08:00
Vidar Holen 7fda86d6e2 Fixed warning for 'exec foo; exit 3' 2013-11-24 14:48:12 -08:00
Vidar Holen 6905373b6c Fix incorrect warning for 'foo > bar 2> bar' 2013-11-24 14:20:24 -08:00
Vidar Holen 1d8401d583 Assume variables have spaces by default 2013-11-17 16:16:58 -08:00
Vidar Holen a89aee1a34 Assume variables have spaces/globs by default 2013-11-17 16:13:45 -08:00
Vidar Holen 4853dce3fe Fixed wrong quoting warning for foo=" "; foo 2013-11-17 15:00:07 -08:00
Vidar Holen a793e09bab Added hint to suggest missing ;; in case 2013-11-17 14:41:55 -08:00
Vidar Holen d8b5d6393a \" should not be treated specially in `backticks` 2013-11-12 18:27:18 -08:00
Vidar Holen d404bc703d Show expose error code in shellcheck frontends 2013-11-10 12:22:33 -08:00
Vidar Holen e5e08df1d9 Numbered messages 2013-11-10 10:55:46 -08:00
Vidar Holen 83c3dd3418 Accept ./? in function names 2013-11-03 13:58:06 -08:00
Vidar Holen 8d265aa25e Don't warn about expr if using : operator 2013-11-03 13:47:04 -08:00
Vidar Holen 71bc26aefa Fixed parsing of | outside of groups in =~ regex 2013-11-03 13:13:24 -08:00
Vidar Holen 8a3d259ae6 Don't warn about single quotes in args to perl 2013-11-03 12:47:44 -08:00
Vidar Holen 3a9ae0ebf1 Accept dir-/basename due to edge cases like "/" and "foo" 2013-11-03 12:42:11 -08:00
Vidar Holen 6d0bfcf37a Fixed parser accepting spaces after here doc token 2013-10-27 16:02:27 -07:00
Vidar Holen e0bbb89d00 Fixed parser bug where }> wasn't recognized as Rbrace 2013-10-27 15:36:47 -07:00
Vidar Holen b1af7bb8f2 Fixed parser error for 'for ((;;)) ; do' 2013-10-11 20:03:55 -07:00
Vidar Holen 157fea73da Suggest ./* instead of * for command arguments 2013-10-06 15:54:31 -07:00
Vidar Holen b439f02b8e Improved assignment parsing: track indices and += vs = 2013-10-06 14:44:43 -07:00
Vidar Holen 710a28c572 Revert "Fixed parsing for 'eval var=(values)'", because it fails for 'eval $x=foo'
This reverts commit 34e69556b1.
2013-09-29 21:35:20 -07:00
Vidar Holen 702d57b655 Warn about unicode quotes 2013-09-29 21:22:42 -07:00
Vidar Holen 34e69556b1 Fixed parsing for 'eval var=(values)' 2013-09-29 21:00:29 -07:00
Vidar Holen 7c411b39ac Fixed warnings for read -p "Name: " 2013-09-29 20:55:26 -07:00
Vidar Holen 5a959bc340 Fix parser errors for unclosed $( in here docs 2013-09-21 16:27:17 -07:00
Vidar Holen fb5f72951d Don't warn about unused variables for read '' 2013-09-12 19:11:42 -07:00
Vidar Holen 7630136d6c Move command and variable lists to ShellCheck.Data. 2013-09-12 18:50:33 -07:00
Vidar Holen dacb8c597f Fixed a series of extglob parsing oddities and edge cases 2013-09-04 13:02:30 -07:00
Vidar Holen 58b8e0ab70 Suggest pgrep when grepping ps 2013-08-31 18:32:07 -07:00
Vidar Holen 9586a46c9c Warn about assigned but unreferenced variables 2013-08-31 18:26:20 -07:00
Vidar Holen bb49cf8e65 Parse the contents of unquoted here documents 2013-08-31 17:03:15 -07:00
Vidar Holen de1fa61560 Warn about client side expansion in ssh strings/heredocs. 2013-08-03 21:19:32 -07:00
Vidar Holen 07b1fd6f44 Allow :+- in function names. :(){ :|:;};:, anyone? 2013-08-03 20:22:32 -07:00
Vidar Holen d0caa1e1df Don't warn for 'find .. | xargs -0' or 'ls -N | ..' 2013-07-25 19:58:53 -07:00
Vidar Holen 62566ee016 Clarified warning for expr 2013-07-24 00:17:31 -07:00
Vidar Holen c1731bd72c Don't warn about redirecting sudo to /dev/null 2013-07-23 23:46:40 -07:00
Vidar Holen 4d9f8ebb39 Allow lack of spaces/separators in for((;;))do .. 2013-07-23 23:30:48 -07:00
Vidar Holen 6aab109afb Fixed up some warning messages. 2013-07-23 23:13:28 -07:00
Vidar Holen 8c5f0a062e Warn about suspicious quotes in "foo "$var" bar" 2013-07-23 22:48:35 -07:00
Vidar Holen 5ba382d79b Fixed parsing of IFS= read as single assignment 2013-07-23 22:12:13 -07:00
Vidar Holen d28f1fff56 Tried to make [ foo=bar ] messages simpler 2013-07-23 21:53:01 -07:00
Vidar Holen 1784972af7 Don't warn about echo "--------" is posix mode 2013-07-23 21:40:55 -07:00
Vidar Holen 6974497f45 Don't warn for \. (regex) and \, (printf "%q" output) 2013-07-23 21:35:00 -07:00
Vidar Holen b147419717 Don't warn for $ on $(( ${array[refs]} )) 2013-07-23 21:29:19 -07:00
Vidar Holen d6dab3bd05 Don't warn about IFS= read .. 2013-07-23 21:23:33 -07:00
Vidar Holen cd1368b434 Added $PWD as a variable likely to contain spaces 2013-07-23 21:03:43 -07:00
Vidar Holen f348661e7e Generalized for f in $(ls) warning, due to many edge cases. 2013-07-23 20:54:04 -07:00
Vidar Holen 9393e4405b Fixed accidental warning for $".." 2013-07-11 09:32:13 -07:00
Vidar Holen e84d5abc3e Support for recursive regex groups 2013-07-10 23:47:25 -07:00
Vidar Holen 0a2314cdcd Also allow array syntax for args to readonly. 2013-07-10 23:15:08 -07:00
Vidar Holen 3e39411b38 Don't suggest ${foo//bar/baz} for #!/bin/sh 2013-07-10 23:14:10 -07:00
Vidar Holen 2214889a36 Improved messages for missing spaces in [..] 2013-07-10 23:03:42 -07:00
Vidar Holen 5a3493740e Warn for [ \( foo = bar\) ] 2013-07-10 18:05:51 -07:00
Vidar Holen e6f2ee1f88 Don't try to parse $'..' in "" 2013-07-10 17:41:38 -07:00
Vidar Holen 3832ca9d5c Simplified PS1 checks. 2013-07-09 23:43:27 -07:00
Vidar Holen 636c6a9336 Parser support for export a=(b c). Also declare/local/typeset. 2013-07-09 23:32:13 -07:00
Vidar Holen 6b9cad55a5 Better unquoted message, seeing as how it's so common. 2013-07-09 22:18:22 -07:00
Vidar Holen 4780da31c2 Added bashism warning for &> 2013-07-09 22:11:17 -07:00
Vidar Holen d04262c70f Fixed broken recursive backtick expansion. 2013-07-09 21:53:15 -07:00
Vidar Holen 8055b6f9c5 Fixed warning for trap '$VAR' 2013-07-09 09:26:48 -07:00
Vidar Holen c3211e559d Added check for for f in $(find ..) similar to $(ls) 2013-07-08 21:09:27 -07:00
Vidar Holen 3d47609e78 Warn for [ $foo = *glob* ] 2013-07-08 20:45:15 -07:00
Vidar Holen 52f2f71b40 Added missing id/recursing defintions for DollarBracket 2013-07-08 09:51:57 -07:00
Vidar Holen 599beff5b1 Moved shebang verification to parser 2013-07-08 09:39:54 -07:00
Vidar Holen a08e60cd07 Don't try to parse scripts declared as perl, ruby or python 2013-07-07 13:22:29 -07:00
Vidar Holen 2500b2cce6 Fixed parser warning for \{foo,bar\} 2013-07-06 15:36:06 -07:00
Vidar Holen 56e0119db1 Fixed some incorrect warnings for PS1 escapes. 2013-07-05 19:12:13 -07:00
Vidar Holen 76c5af2973 Parser support for $[..], plus deprecation warning. 2013-07-05 09:42:08 -07:00
Vidar Holen fc4a6043d7 Reformatted ugly AST definition 2013-07-05 09:24:22 -07:00
Vidar Holen a20a3499ed Improved bad indirection detection 2013-07-05 09:15:08 -07:00
Vidar Holen 73c6202842 Fixed misplaced uuoc for 'cat foo' outside pipe. 2013-07-04 14:27:03 -07:00
Vidar Holen 10b5e44ad0 Improved help for missing here doc terminator. 2013-07-04 14:19:54 -07:00
Vidar Holen 66cebe7c7b Don't warn about quoting when $var is the command name. 2013-07-04 13:49:00 -07:00
Vidar Holen af4d24c6f6 Check for 'echo "\n"'. 2013-07-04 13:42:31 -07:00
Vidar Holen fc3045232f Don't warn about f=/dev/null in 'foo $f > $f' 2013-07-04 13:18:46 -07:00
Vidar Holen dbd4ff109c Mention second level structure being parsed when error. 2013-07-04 13:07:27 -07:00
Vidar Holen d2c5802a9d Fixed UUOC warning for 'cat * | ..'. 2013-07-04 12:26:59 -07:00
Vidar Holen ab20747ef2 Removed warning for ~ in the middle of strings. Too common. 2013-07-04 12:01:34 -07:00
Vidar Holen 9e84ff66f7 Warn about $() but not quotes in 'if $(cmd); ..' 2013-07-04 11:44:36 -07:00
Vidar Holen b060370b92 Added and improved parse warnings for missing spaces. 2013-07-03 16:37:58 -07:00
Vidar Holen f557ac3324 Added check for 'exec foo; cmd' 2013-07-02 22:37:33 -07:00
Vidar Holen 5d46c8a53f Added check for functions used with sudo/xargs/etc 2013-07-02 21:35:17 -07:00
Vidar Holen 99be2736a1 Doubled speed by applying all checks in one iteration. 2013-07-02 20:29:07 -07:00
Vidar Holen 6aafc86a67 Added check for './ file'. Apparently people do that. 2013-07-02 20:09:01 -07:00
Vidar Holen 9cfa25cb56 Added check for ~ in quotes 2013-07-02 19:52:09 -07:00
Vidar Holen 499f7c8733 Warn for possible bad quote nesting like 'echo 'foo'' 2013-07-01 10:01:58 -07:00
Vidar Holen 651bab73de Fixed crash for ''foo due to unsafe 'last' 2013-07-01 09:14:33 -07:00
Vidar Holen 652f8a24fa Added most checks from 'checkbashisms'. Thanks to Braakman, Rodin and Gilbey! 2013-06-30 12:13:18 -07:00
Vidar Holen f820298b6e Added recursive parsing support for `..` 2013-06-26 21:04:39 -07:00
Vidar Holen 25ee7e20f4 Added awkward check for PS1 escapes outside \[..\] 2013-06-25 20:59:54 -07:00
Vidar Holen 438c4ec572 Fixed up warnings for \r, and added warnings for   2013-06-21 01:22:11 -07:00
Vidar Holen 5794f3d390 Fixed parsing of "test$" 2013-06-21 00:33:20 -07:00
Vidar Holen 092073d0b3 Fixed parsing for case foo \n in .. 2013-06-20 23:57:08 -07:00
Vidar Holen 51cd951baa Added warnings for sudo cmd > file 2013-06-18 20:08:56 -07:00
Vidar Holen 3b246f94a3 Fixed parsing for cmd &> file 2013-06-18 20:08:33 -07:00
Vidar Holen 564e3c5413 Don't start comments for #s in the middle of words. Thanks Mitch! 2013-06-07 18:32:59 -07:00
Vidar Holen 103b037921 Fixed parsing for [] in =~ regex 2013-05-31 14:22:13 -07:00
Vidar Holen 1b8b3b84d0 Fixed broken test for for f in "*.mp3"; do .. 2013-05-29 21:05:15 -07:00
Vidar Holen 1dbbc51f86 Improved regex parsing. To think [[ f =~ f( ]] )* ]] is valid.. 2013-05-28 21:32:15 -07:00
Vidar Holen 6b89f33d0c Warn about arg='--foo="bar"'; cmd $arg 2013-05-28 20:06:20 -07:00
Vidar Holen b279411d70 Rewrote variable tracking code for future expansion 2013-05-27 20:54:03 -07:00
Vidar Holen fc1af1b918 Also check for overridden time parameters for /bin/sh 2013-05-25 22:43:17 -07:00
Vidar Holen 17cf796486 Different checks per shell, and increased bashism detection. 2013-05-25 22:33:21 -07:00
Vidar Holen cf67bf2294 Added check for 'time --format' and such, which Bash swallows. 2013-05-23 22:28:12 -07:00
Vidar Holen e8a0fe09bf Added error for ${foo$n} 2013-05-23 21:47:25 -07:00
Vidar Holen 7ae5351de3 Added warning for foo$n=42 2013-05-23 21:31:29 -07:00
Vidar Holen 034cfee66e Fixed glob parsing for [[:class:]] and [~.:]. Thanks to dualbus! 2013-05-23 20:44:28 -07:00
Vidar Holen 13d4ea6540 Don't complaing about lack of quotes for 'local' and 'declare' 2013-05-20 11:58:08 -07:00
Vidar Holen 92d0ae8b6b Allow [ foo \> bar ], while warning for [[ .. \> .. ]] and [ 1 \< 2 ] 2013-05-14 15:59:58 -07:00
Vidar Holen 10d4abf235 Warn for test n > 4 2013-05-14 15:23:28 -07:00
Vidar Holen ce0b313b93 Better messages for ignored backslashes like 'echo foo\n' 2013-05-13 09:15:45 -07:00
Vidar Holen 2f21ced552 Warn for subshell modifications using 'let' 2013-05-02 12:38:47 -07:00
Vidar Holen 82b16b4076 Warn for [[ $foo > 3.14 ]] 2013-03-22 17:10:30 -07:00
Vidar Holen 6abb5fe72b Quick hack to read and discard array indexing in arithmetic contexts 2013-03-22 16:42:40 -07:00
Vidar Holen 9f244edae3 Warn on "grep foo*.jpg" and "grep *foo*" 2013-03-01 17:28:41 -08:00
Vidar Holen d2e2d06978 Add check for [[ "foo" ]] 2013-02-14 19:43:43 -08:00
Vidar Holen 585529a636 Return list of notes rather than a Map -> Map 2013-02-11 19:26:40 -08:00
Vidar Holen 05cb806642 Also warn for '$((foo)) $(cmd) ${foo}', not just '$foo' 2013-02-07 17:53:47 -08:00
Vidar Holen 795af72cf7 Fixed warning for ${#@} 2013-02-06 22:35:24 -08:00
Vidar Holen 899d9eb445 Warn against open parenthesis in normal words 2013-02-05 20:35:39 -08:00
Vidar Holen 84f87002b7 Split up numerical and legal binary op function 2013-02-05 20:15:13 -08:00
Vidar Holen e64698dc78 Improved empty then/elif/else clause errors 2013-01-26 17:21:34 -08:00
Vidar Holen dd115a6d35 Warn on trap "echo $num" USR1 2013-01-25 20:32:25 -08:00
Vidar Holen f6f05234bf Warn on for f in 1,2,3 and for f in ls; 2013-01-25 20:15:42 -08:00