mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Update banned_commands.bats
Update banned_commands.bats so commands in comments are ignored and output is only printed when a banned command is found.
This commit is contained in:
parent
f125741fb5
commit
e121a93716
@ -38,8 +38,18 @@ teardown() {
|
||||
for cmd in "${banned_commands[@]}"; do
|
||||
# Assert command is not used in the lib and bin dirs
|
||||
# or expect an explicit comment at end of line, allowing it.
|
||||
run bash -c "grep -nHR '$cmd' lib bin | grep -v '# asdf_allow: $cmd'"
|
||||
echo "banned command $cmd: $output"
|
||||
# Also ignore matches that are contained in comments or followed by an
|
||||
# underscore (indicating it's a variable and not a command).
|
||||
run bash -c "grep -nHR '$cmd' lib bin\
|
||||
| grep -v '#.*$cmd'\
|
||||
| grep -v '${cmd}_'\
|
||||
| grep -v '# asdf_allow: $cmd'"
|
||||
|
||||
# Only print output if we've found a banned command
|
||||
if [ "$status" -ne 1 ]; then
|
||||
echo "banned command $cmd: $output"
|
||||
fi
|
||||
|
||||
[ "$status" -eq 1 ]
|
||||
[ "" == "$output" ]
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user