Apply suggestions from code review

pull/104/head
IceCodeNew 2020-09-19 17:33:37 +08:00 committed by GitHub
parent cd8d0d4870
commit b8ca436e1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 8 deletions

View File

@ -120,35 +120,39 @@ judgment_parameters() {
;; ;;
'--version') '--version')
VERSION="${2:?error: Please specify the correct version.}" VERSION="${2:?error: Please specify the correct version.}"
break ##跳出while break
;; ;;
'-c' | '--check') '-c' | '--check')
CHECK='1' CHECK='1'
break ##跳出while break
;; ;;
'-f' | '--force') '-f' | '--force')
FORCE='1' FORCE='1'
break ##跳出while break
'-h' | '--help')
HELP='1'
break
;;
;; ;;
'-l' | '--local') '-l' | '--local')
LOCAL_INSTALL='1' LOCAL_INSTALL='1'
LOCAL_FILE="${2:?error: Please specify the correct local file.}" LOCAL_FILE="${2:?error: Please specify the correct local file.}"
break ##跳出while break
;; ;;
'-p' | '--proxy') '-p' | '--proxy')
if echo "${2:?undefine var}" | grep -qEo '^(http|https|socks4|socks4a|socks5|socks5h)://'; then if echo "${2:?undefine var}" | grep -qEo '^(https?|socks4a?|socks5h?):\/\/'; then
echo 'error: Please specify the correct proxy server address.' echo 'error: Please specify the correct proxy server address.'
exit 1 exit 1
fi fi
PROXY="-x$2" PROXY="-x$2"
shift ## 参数左移 shift
;; ;;
*) *)
show_help show_help
exit 1 exit 1
;; ;;
esac esac
shift ## 参数左移 shift
done done
} }
@ -423,7 +427,7 @@ main() {
judgment_parameters "$@" judgment_parameters "$@"
# Parameter information # Parameter information
# [[ "$HELP" -eq '1' ]] && show_help [[ "$HELP" -eq '1' ]] && show_help
[[ "$CHECK" -eq '1' ]] && check_update [[ "$CHECK" -eq '1' ]] && check_update
[[ "$REMOVE" -eq '1' ]] && remove_v2ray [[ "$REMOVE" -eq '1' ]] && remove_v2ray