From 64dbbde4735697421df31592a243879f4c7847a2 Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Fri, 7 May 2021 16:41:51 +1200 Subject: [PATCH] Use type builtin to check for the existence of the curl command. There is no need to actually execute curl in order to check that it exists on the system, the type builtin can tell us without having to fork the command. --- centos2rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centos2rocky.sh b/centos2rocky.sh index e54ff78..1769dde 100755 --- a/centos2rocky.sh +++ b/centos2rocky.sh @@ -23,7 +23,7 @@ if [[ "$(id -u)" -ne 0 ]]; then "${errcolor}Either use sudo or 'su -c ${0}'$nocolor" fi -if [[ "$(curl 2>/dev/null || echo $?)" == 127 ]]; then +if ! type curl >/dev/null 2>&1; then printf "${blue}Curl is not installed! Installing it...$nocolor" dnf -y install curl libcurl fi