From 463004df769a2bae5cfea5f85c262fc13c70fbbe Mon Sep 17 00:00:00 2001 From: typebrook Date: Fri, 7 Feb 2020 12:10:05 +0800 Subject: update --- scripts/gist | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 2ac7fd7..1222e82 100755 --- a/scripts/gist +++ b/scripts/gist @@ -15,7 +15,7 @@ # new, n [-d | --desc ] ... create a new gist with files # new, n [-d | --desc ] [-f | --file ] create a new gist from STDIN # detail, d show the detail of a gist -# edit, e edit a gist description +# edit, e edit a gist's description # delete, D ... delete a gist # clean, C clean removed gists in local # config, c [token | user | folder | auto_sync | EDITOR | action [value] ] do configuration @@ -49,15 +49,17 @@ _configure() { [[ -z "$@" ]] && (${EDITOR:-vi} $CONFIG) && return 0 local target="" - if [[ $1 == 'user' ]]; then - [[ -z $2 ]] && echo "Must specify username" >&2 && return 1 - elif [[ $1 == 'token' ]]; then - [[ ${#2} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 \ - && return 1 - elif [[ $1 == 'auto_sync' ]]; then - [[ ! $2 =~ ^(true|false)$ ]] && return 1 + if [[ $1 =~ ^(user|token|folder|auto_sync|EDITOR|action)$ ]]; then + if [[ $1 == 'user' ]]; then + [[ -z $2 ]] && echo "Must specify username" >&2 && return 1 + elif [[ $1 == 'token' ]]; then + [[ ${#2} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 \ + && return 1 + elif [[ $1 == 'auto_sync' ]]; then + [[ ! $2 =~ ^(true|false)$ ]] && return 1 + fi + target=$1=$2 fi - target=$1=$2 umask 0077 && touch $CONFIG sed -i "/^$1=/ d" $CONFIG && [[ "$target" =~ [^=]$ ]] && echo $target >> $CONFIG -- cgit v1.2.3-70-g09d2