From 5f27592fb4d2056dca40e0a65ef8405cb43721d1 Mon Sep 17 00:00:00 2001 From: "xiongdian.me" Date: Wed, 24 May 2023 16:36:28 +0800 Subject: [PATCH] common.sh: argparser supports -d/--dev and -D/--dry-run --- install.sh | 1 - scripts/riot | 3 ++- tools/common.sh | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 04717cf..f090241 100755 --- a/install.sh +++ b/install.sh @@ -319,7 +319,6 @@ for i in ${GOT_OPTS[@]}; do case $i in -i ) FUNC=install ;; -r ) FUNC=uninstall ;; - -d|--dev ) export DFS_DEV=1; set -x ;; -a|--auto ) INSTALL_DEP=1 ;; -s|--secure ) export DFS_DEV=0 ;; -H|--hist|--history ) store_hist=1 ;; diff --git a/scripts/riot b/scripts/riot index 9ccffe6..2342bcc 100755 --- a/scripts/riot +++ b/scripts/riot @@ -115,7 +115,7 @@ eval_or_echo() { fi } -# ssh +# ssh series prepare_ssh_cmd() { local ssh_bin="${1:-ssh}" if [[ "$ssh_bin" == "scp" || "$ssh_bin" == "sftp" ]]; then @@ -126,6 +126,7 @@ prepare_ssh_cmd() { echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST" } +# ssh run_ssh() { local cmd="$(prepare_ssh_cmd $1)" diff --git a/tools/common.sh b/tools/common.sh index a1d091b..4cc6c6b 100755 --- a/tools/common.sh +++ b/tools/common.sh @@ -3,7 +3,7 @@ set -e THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd ) if [[ -f ~/.config/dotfiles/env ]]; then set -a; source ~/.config/dotfiles/env; set +a; fi -if [[ "$DFS_DEBUG" == "1" ]]; then set -x; fi +if [[ "$DFS_DEV" == "1" ]]; then set -x; fi DFS_CURL_OPTIONS="--retry 2 --max-time 20" # parse args and set env, when it is sourced @@ -17,8 +17,9 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then case $ARG in -q*|--quite ) export DFS_QUIET=1 ;; -l*|--lite ) export DFS_LITE=1 ;; + -d*|--dev ) export DFS_DEV=1; set -x ;; + -D*|--dry-run ) export DFS_DRY_RUN=1 ;; --color ) export DFS_COLOR=1 ;; - --dry-run ) export DFS_DRY_RUN=1 ;; # TODO!!! --*=* ) GOT_OPTS+=("${ARG%%=*}" "${ARG#*=}") ;; --* ) GOT_OPTS+=("$ARG") ;; -* ) GOT_OPTS+=("${ARG:0:2}") ;;