Mercurial > forks > mercurial
changeset 53274:e61533488826 stable
check-code: tighten up the check for shell assignment and export
The `export` pattern is the start of the word, the variable name is alphanumeric
or underscore (but must start with a letter or underscore), and is separated by
a space or tab. The previous check wrongly flagged this command in a *.t file:
$ hg fastexport --color=never >/dev/null
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 15 May 2025 22:41:51 -0400 |
parents | fb8373b37f6e |
children | c6ebaa66d411 |
files | contrib/check-code.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Tue May 13 12:04:47 2025 +0200 +++ b/contrib/check-code.py Thu May 15 22:41:51 2025 -0400 @@ -152,7 +152,10 @@ (r'(?<!!)/bin/', "don't use explicit paths for tools"), (r'#!.*/bash', "don't use bash in shebang, use sh"), (r'[^\n]\Z', "no trailing newline"), - (r'export .*=', "don't export and assign at once"), + ( + r'\bexport[ \t]+[_a-zA-Z][_a-zA-Z0-9]*=', + "don't export and assign at once", + ), (r'^source\b', "don't use 'source', use '.'"), (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"), (r'\bls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),