core: 用 which 判断命令是否存在

This commit is contained in:
bin456789 2023-09-21 00:12:48 +08:00
parent 4f9c2a7415
commit d501d66de9
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -576,10 +576,11 @@ install_pkg() {
is_in_windows && return
for cmd in "$@"; do
if ! command -v $cmd ||
# 用 which 而不是 command -v因为 command -v 把脚本中的function也算在内
if ! which $cmd >/dev/null ||
# gentoo 默认编译的 unsquashfs 不支持 xz
{ [ "$cmd" = unsquashfs ] &&
command -v emerge &&
which emerge >/dev/null &&
! unsquashfs |& grep -w xz &&
echo "unsquashfs not supported xz. need rebuild."; }; then