Commit c4e38033 authored by Kevin Daudt's avatar Kevin Daudt

apkbuild-lint: allow double underscore as argument

apkbuild-lint guards against parameters starting with a double
underscore as they are reserved. But the check for this is a bit too
eager and also warns when something starts with a double underscore
which is not a variable.

For example:

```sh
function foo() {
    make -D__VAR=value
}
```

is a legal construct, but this resulted in a warning. This is because
the start-of-string / tab part was marked optional, which makes the test
look for anything starting with a double underscore.

Remove the `?` from the group to actual anchor the check.

Fixes #24
parent 9734ff98
......@@ -235,7 +235,7 @@ double_underscore_in_variable() {
# which requires matching the = sign at the end. The second time will match
# for variables declared with the local keyword which do not require the =
# sign
scan '(^|\t)?__[A-Za-z0-9_].*=' 'double underscore on variables are reserved' 'AL30' 'MC'
scan '(^|\t)__[A-Za-z0-9_].*=' 'double underscore on variables are reserved' 'AL30' 'MC'
scan '(^|\t)local ([A-Za-z0-9_])?.*__[A-Za-z0-9_].*(=)?' 'double underscore on variables are reserved' 'AL30' 'MC'
}
......
......@@ -651,6 +651,17 @@ is_travis() {
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'double underscore as argument should be allowed' {
cat <<-"EOF" >$apkbuild
foo() {
make -D__VAR=val
}
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'capitalized variable' {
cat <<-"EOF" >$apkbuild
Foo=bar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment