From 5d1f30f66e7f4dbc03e97dd04a3f5eff392a3bdb Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 13 Feb 2025 00:34:49 +0800 Subject: [PATCH] fix: null-coalescing operator: // " --- script/clashctl.sh | 2 +- script/common.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/script/clashctl.sh b/script/clashctl.sh index 7af8fa3..1e3be46 100644 --- a/script/clashctl.sh +++ b/script/clashctl.sh @@ -61,7 +61,7 @@ _merge_config_restart() { function clashsecret() { case "$#" in 0) - _okcat "当前密钥:$(sudo "$BIN_YQ" '.secret' "$CLASH_CONFIG_RUNTIME")" + _okcat "当前密钥:$(sudo "$BIN_YQ" '.secret // ""' "$CLASH_CONFIG_RUNTIME")" ;; 1) local secret=$1 diff --git a/script/common.sh b/script/common.sh index 98eb46d..1184ba3 100644 --- a/script/common.sh +++ b/script/common.sh @@ -46,7 +46,7 @@ function _get_os() { CLASH_CRON_TAB='/var/spool/cron/crontabs/root' BASHRC='/etc/bash.bashrc' } - + _get_kernel local cpu_arch=$(uname -m) # shellcheck disable=SC2086 @@ -54,9 +54,9 @@ function _get_os() { } function _get_port() { - local port=$(sudo $BIN_YQ '.port' $CLASH_CONFIG_RUNTIME) - local mixed_port=$(sudo $BIN_YQ '.mixed-port' $CLASH_CONFIG_RUNTIME) - local external_port=$(sudo $BIN_YQ '.external-controller' $CLASH_CONFIG_RUNTIME | cut -d':' -f2) + local port=$(sudo $BIN_YQ '.port // ""' $CLASH_CONFIG_RUNTIME) + local mixed_port=$(sudo $BIN_YQ '.mixed-port // ""' $CLASH_CONFIG_RUNTIME) + local external_port=$(sudo $BIN_YQ '.external-controller // ""' $CLASH_CONFIG_RUNTIME | cut -d':' -f2) PROXY_PORT="${mixed_port:-${port:-7890}}" UI_PORT=${external_port:-9090}