From 0d128dd918be22b764d1625393775eb4080ca006 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 15 Oct 2021 12:06:33 -0700 Subject: [PATCH] Mention known incompatibilities in man page --- shellcheck.1.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/shellcheck.1.md b/shellcheck.1.md index 1103acc..b1f0c25 100644 --- a/shellcheck.1.md +++ b/shellcheck.1.md @@ -335,10 +335,32 @@ locales where encoding is unspecified (such as the `C` locale). Windows users seeing `commitBuffer: invalid argument (invalid character)` should set their terminal to use UTF-8 with `chcp 65001`. -# AUTHORS +# KNOWN INCOMPATIBILITIES -ShellCheck is developed and maintained by Vidar Holen, with assistance from a -long list of wonderful contributors. +(If nothing in this section makes sense, you are unlikely to be affected by it) + +To avoid confusing and misguided suggestions, ShellCheck requires function +bodies to be either `{ brace groups; }` or `( subshells )`, and function names +containing `[]*=!` are only recognized after a `function` keyword. + +The following unconventional function definitions are identical in Bash, +but ShellCheck only recognizes the latter. + + [x!=y] () [[ $1 ]] + function [x!=y] () { [[ $1 ]]; } + +Shells without the `function` keyword do not allow these characters in function +names to begin with. Function names containing `{}` are not supported at all. + +Further, if ShellCheck sees `[x!=y]` it will assume this is an invalid +comparison. To invoke the above function, quote the command as in `'[x!=y]'`, +or to retain the same globbing behavior, use `command [x!=y]`. + +ShellCheck imposes additional restrictions on the `[` command to help diagnose +common invalid uses. While `[ $x= 1 ]` is defined in POSIX, ShellCheck will +assume it was intended as the much more likely comparison `[ "$x" = 1 ]` and +fail accordingly. For unconventional or dynamic uses of the `[` command, use +`test` or `\[` instead. # REPORTING BUGS @@ -346,6 +368,11 @@ Bugs and issues can be reported on GitHub: https://github.com/koalaman/shellcheck/issues +# AUTHORS + +ShellCheck is developed and maintained by Vidar Holen, with assistance from a +long list of wonderful contributors. + # COPYRIGHT Copyright 2012-2019, Vidar Holen and contributors.