Commit 108a3b0c authored by Yuanle Song's avatar Yuanle Song
Browse files

bugfix: should check exit code before check whether "$MYIP" is empty.

parent e42d3401
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -103,10 +103,6 @@ get_myip() {
	if type get_ip_command > /dev/null 2>&1; then
		get_ip_command
		EXIT_CODE=$?
		if [ -z "$MYIP" ]; then
			err "Error: get_ip_command did not set MYIP variable."
			exit $GET_MYIP_FAILED
		fi
	else
		MYIP=`curl -s http://ifconfig.me`
		EXIT_CODE=$?
@@ -117,6 +113,11 @@ get_myip() {
		exit $GET_MYIP_FAILED
	fi

	if [ -z "$MYIP" ]; then
		err "Error: get_ip_command did not set MYIP variable."
		exit $GET_MYIP_FAILED
	fi

	if echo "$MYIP" | egrep -q -e '^[0-9]{1,3}(\.[0-9]{1,3}){3}$'; then
		return 0
	else