不使用 brew,我如何检测在运行我的bash脚本的Mac上是否安装了coreutils。
这是我的脚本:
#!/usr/bin/env bash
check_bash_version () {
echo "checking which bash version is installed...."
sleep 3
echo "Bash versioncheck completed"
sleep 1
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
echo "You need to be using Bash version =< 4. Please upgrade"
exit 1
fi
}
check_coreutils () {
echo "checking if coreutils is installed...."
sleep 3
# what goes here
}
main() {
# Main function.
# check if MacOS
if [[ "$(uname)" == "Darwin" ]]; then
check_bash_version
check_coreutils
fi
}
--version
。