diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-04-16 21:50:27 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-04-16 21:50:27 (GMT) |
commit | 92e8388bd35cdddf312011a98e046706bb420fce (patch) | |
tree | 76f64ac160dc18e2ae956a67525d9c64c8107839 /Documentation | |
parent | 548fe35913139eba2981be718f7b4dff7d0412d5 (diff) | |
parent | 836b22139115f92812479ff6a92ffad09f8a6b8c (diff) | |
download | git-92e8388bd35cdddf312011a98e046706bb420fce.zip git-92e8388bd35cdddf312011a98e046706bb420fce.tar.gz git-92e8388bd35cdddf312011a98e046706bb420fce.tar.bz2 |
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
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/CodingGuidelines | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index ab39509..1d92b2d 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -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. |