Merge branch 'jc/local-extern-shell-rules'
Document and apply workaround for a buggy version of dash that
mishandles "local var=val" construct.
* jc/local-extern-shell-rules:
t1016: local VAR="VAL" fix
t0610: local VAR="VAL" fix
t: teach lint that RHS of 'local VAR=VAL' needs to be quoted
t: local VAR="VAL" (quote ${magic-reference})
t: local VAR="VAL" (quote command substitution)
t: local VAR="VAL" (quote positional parameters)
CodingGuidelines: quote assigned value in 'local var=$val'
CodingGuidelines: describe "export VAR=VAL" rule
This commit is contained in:
@@ -188,6 +188,22 @@ For shell scripts specifically (not exhaustive):
|
||||
hopefully nobody starts using "local" before they are reimplemented
|
||||
in C ;-)
|
||||
|
||||
- Some versions of shell do not understand "export variable=value",
|
||||
so we write "variable=value" and then "export variable" on two
|
||||
separate lines.
|
||||
|
||||
- Some versions of dash have broken variable assignment when prefixed
|
||||
with "local", "export", and "readonly", in that the value to be
|
||||
assigned goes through field splitting at $IFS unless quoted.
|
||||
|
||||
(incorrect)
|
||||
local variable=$value
|
||||
local variable=$(command args)
|
||||
|
||||
(correct)
|
||||
local variable="$value"
|
||||
local variable="$(command args)"
|
||||
|
||||
- Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g.
|
||||
"\xc2\xa2") in printf format strings, since hexadecimal escape
|
||||
sequences are not portable.
|
||||
|
||||
Reference in New Issue
Block a user