get.sh xbget: don't use eval for file/dir checks

the actual code works fine, but it's quite hacky.

there are times when use of eval is acceptable; this
is not one of those times, but i'd used it in this
instance when i was being a bit crazy about code size
reductions during my audits.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-09-02 03:22:12 +01:00
parent 934e89510e
commit e059614589

View File

@@ -77,12 +77,13 @@ xbget()
[ "$1" = "curl" ] || [ "$1" = "copy" ] || [ "$1" = "git" ] || \
err "Bad dlop (arg 1): xbget $*"
echk="f" && [ "$1" = "git" ] && echk="d"
for url in "$2" "$3"; do
[ -n "$url" ] || err "empty URL given in: xbget $*"
try_file "$url" "$@" || continue
eval "[ -$echk \"$4\" ] || continue"
case "$1" in
git) [ -d "$4" ] || continue ;;
*) [ -f "$4" ] || continue ;;
esac
return 0 # successful download/copy
done
err "$1 $2 $3 $4: not downloaded"; :