From 0938ab431a001fced7b6a6ecace89a08ae0e3398 Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 13 Apr 2020 14:16:29 +0800 Subject: Make Command Substitution works with configuration --- gist | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gist b/gist index f4bf032..6ab38fb 100755 --- a/gist +++ b/gist @@ -176,19 +176,21 @@ _configure() { if [[ $key == 'user' ]]; then [[ -z $value ]] && echo 'Must specify username' >&2 && return 1 elif [[ $key == 'token' ]]; then - [[ ${#value} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 + [[ ${#value} -ne 40 && ! $value =~ ^(\$|\`) ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 elif [[ $key =~ ^(auto_sync|show_untagged)$ ]]; then [[ ! $value =~ ^(true|false)$ ]] && echo "$key must be either true or false" >&2 && return 1 elif [[ $key == 'protocol' ]]; then [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1 + elif [[ $key == 'action' ]]; then + value="'$2'" fi - shift && local target=$key="'$*'" else echo "Not a valid key for configuration, use <$valid_keys> instead." return 1 fi umask 0077 && touch "$CONFIG" + local target=$key="$value" sed -i'' -e "/^$key=/ d" "$CONFIG" && [[ -n $target ]] && echo "$target" >> "$CONFIG" cat "$CONFIG" } -- cgit v1.2.3-70-g09d2