Răsfoiți Sursa

removed which command as per shellcheck

command is a POSIX and will exclusivly use this moving forward. https://github.com/koalaman/shellcheck/wiki/SC2230
Daniel Gibbs 8 ani în urmă
părinte
comite
bbcf07603d

+ 2 - 2
lgsm/functions/check_deps.sh

@@ -149,7 +149,7 @@ if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
 
 	# All servers except ts3 require tmux
 	if [ "${gamename}" != "TeamSpeak 3" ]; then
-		if [ "$(command -v tmux 2>/dev/null)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
+		if [ "$(command -v tmux 2>/dev/null)" ]; then
 			tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
 		else
 			array_deps_required+=( tmux )
@@ -246,7 +246,7 @@ elif [ -n "$(command -v yum 2>/dev/null)" ]; then
 
 	# All servers except ts3 require tmux
 	if [ "${gamename}" != "TeamSpeak 3" ]; then
-		if [ "$(command -v tmux 2>/dev/null)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
+		if [ "$(command -v tmux 2>/dev/null)" ]; then
 			tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
 		else
 			array_deps_required+=( tmux )

+ 1 - 1
lgsm/functions/command_stop.sh

@@ -118,7 +118,7 @@ fn_stop_graceful_sdtd(){
 	sleep 1
 	if [ "${telnetenabled}" == "false" ]; then
 		fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
-	elif [ "$(command -v expect 2>/dev/null)" ]||[ "$(which expect >/dev/null 2>&1)" ]; then
+	elif [ "$(command -v expect 2>/dev/null)" ]; then
 		# Tries to shutdown with both localhost and server IP.
 		for telnetip in 127.0.0.1 ${ip}; do
 			fn_print_dots "Graceful: telnet: ${telnetip}"

+ 1 - 7
lgsm/functions/core_dl.sh

@@ -238,13 +238,7 @@ fn_update_function(){
 }
 
 # Defines curl path
-curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
-for curlpath in "${curl_paths_array}"
-do
-	if [ -x "${curlpath}" ]; then
-		break
-	fi
-done
+curlpath=$(command -v curl 2>/dev/null)
 
 if [ "$(basename ${curlpath})" != "curl" ]; then
 	echo "[ FAIL ] Curl is not installed"

+ 1 - 1
lgsm/functions/update_ts3.sh

@@ -206,7 +206,7 @@ fn_update_ts3_compare(){
 fn_update_ts3_arch
 if [ "${installer}" == "1" ]; then
 	# if jq available uses json update checker
-	if [ "$(command -v jq)" ]||[ "$(which jq >/dev/null 2>&1)" ]; then
+	if [ "$(command -v jq >/dev/null 2>&1)" ]; then
 		fn_update_ts3_availablebuild
 	else
 		fn_update_ts3_availablebuild_legacy

+ 4 - 9
linuxgsm.sh

@@ -70,13 +70,8 @@ fn_bootstrap_fetch_file(){
 			mkdir -p "${local_filedir}"
 		fi
 		# Defines curl path
-		curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
-		for curlpath in "${curl_paths_array}"
-		do
-			if [ -x "${curlpath}" ]; then
-				break
-			fi
-		done
+		curlpath=$(command -v curl 2>/dev/null)
+
 		# If curl exists download file
 		if [ "$(basename ${curlpath})" == "curl" ]; then
 			# trap to remove part downloaded files
@@ -198,8 +193,8 @@ fn_install_menu() {
 	options=$4
 	# Get menu command
 	for menucmd in whiptail dialog bash; do
-		if [ -x $(which ${menucmd}) ]; then
-			menucmd=$(which ${menucmd})
+		if [ -x $(command -v ${menucmd}) ]; then
+			menucmd=$(command -v ${menucmd})
 			break
 		fi
 	done

+ 4 - 9
tests/tests_jc2server.sh

@@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
 			mkdir -p "${local_filedir}"
 		fi
 		# Defines curl path
-		curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
-		for curlpath in "${curl_paths_array}"
-		do
-			if [ -x "${curlpath}" ]; then
-				break
-			fi
-		done
+		curlpath=$(command -v curl 2>/dev/null)
+
 		# If curl exists download file
 		if [ "$(basename ${curlpath})" == "curl" ]; then
 			# trap to remove part downloaded files
@@ -193,8 +188,8 @@ fn_install_menu() {
 	options=$4
 	# Get menu command
 	for menucmd in whiptail dialog bash; do
-		if [ -x $(which ${menucmd}) ]; then
-			menucmd=$(which ${menucmd})
+		if [ -x $(command -v ${menucmd}) ]; then
+			menucmd=$(command -v ${menucmd})
 			break
 		fi
 	done

+ 4 - 9
tests/tests_ts3server.sh

@@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
 			mkdir -p "${local_filedir}"
 		fi
 		# Defines curl path
-		curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
-		for curlpath in "${curl_paths_array}"
-		do
-			if [ -x "${curlpath}" ]; then
-				break
-			fi
-		done
+		curlpath=$(command -v curl 2>/dev/null)
+
 		# If curl exists download file
 		if [ "$(basename ${curlpath})" == "curl" ]; then
 			# trap to remove part downloaded files
@@ -193,8 +188,8 @@ fn_install_menu() {
 	options=$4
 	# Get menu command
 	for menucmd in whiptail dialog bash; do
-		if [ -x $(which ${menucmd}) ]; then
-			menucmd=$(which ${menucmd})
+		if [ -x $(command -v ${menucmd}) ]; then
+			menucmd=$(command -v ${menucmd})
 			break
 		fi
 	done