Allow eval only on asdf function at lib/asdf.sh.

It's needed for `asdf shell` command.
This commit is contained in:
Victor Hugo Borja 2019-12-03 11:01:04 -06:00
parent d76f639c75
commit 5ab01f49df
2 changed files with 7 additions and 5 deletions

View File

@ -9,7 +9,7 @@ asdf() {
case "$command" in
"shell")
# commands that need to export variables
eval "$(asdf export-shell-version sh "$@")"
eval "$(asdf export-shell-version sh "$@")" # asdf_allow: eval
;;
*)
# forward other commands to asdf script

View File

@ -12,7 +12,7 @@ banned_commands=(
# does not work on alpine and should be grep -i either way
"grep -y"
)
)
setup() {
setup_asdf_dir
@ -25,8 +25,10 @@ teardown() {
@test "banned commands are not found in source code" {
for cmd in "${banned_commands[@]}"; do
# Assert command is not used in the lib and bin dirs
run grep -nHR "$cmd" lib bin
[ "$status" -eq 1 ]
[ "$output" = "" ]
# 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"
[ "$status" -eq 1 ]
[ "" == "$output" ]
done
}