From bc924c9410203af3d574fb610964038b7253e990 Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 10 Feb 2020 12:03:46 +0800 Subject: update --- scripts/gist | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/gist b/scripts/gist index 2f0a3f7..59fbd06 100755 --- a/scripts/gist +++ b/scripts/gist @@ -115,11 +115,11 @@ update() { echo "Error: no active internet connection" >&2 exit 1 else - if [[ "$latestVersion" != "$currentVersion" ]]; then + if [[ $latestVersion != $currentVersion ]]; then echo "Version $latestVersion available" echo -n "Do you wish to update $repositoryName [Y/n]: " read -r answer - if [[ "$answer" == [Yy] ]]; then + if [[ $answer == [Yy] ]]; then cd ~ || { echo 'Update Failed'; exit 1; } if [[ -d ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo "Permissions Error: try running the update as sudo"; exit 1; } ; fi echo -n "Downloading latest version of: $repositoryName." @@ -144,7 +144,7 @@ update() { # handle configuration cases _configure() { - [[ -z "$@" ]] && (${EDITOR:-vi} $CONFIG) && return 0 + [[ -z $@ ]] && (${EDITOR:-vi} $CONFIG) && return 0 local target="" if [[ $1 =~ ^(user|token|folder|auto_sync|EDITOR|action)$ ]]; then @@ -160,7 +160,7 @@ _configure() { fi umask 0077 && touch $CONFIG - sed -i'' -e "/^$1=/ d" $CONFIG && [[ -n "$target" ]] && echo $target >> $CONFIG + sed -i'' -e "/^$1=/ d" $CONFIG && [[ -n $target ]] && echo $target >> $CONFIG cat $CONFIG } @@ -315,7 +315,7 @@ _fetch_gists() { echo local route="users/$user/gists" local filter='/^[^s]/ d; /^$/ d' - if [[ "$1" =~ ^(star|s)$ ]];then + if [[ $1 =~ ^(star|s)$ ]];then route="gists/starred" local mark="s" filter='/^[s]/ d; /^$/ d' @@ -369,7 +369,7 @@ _sync_repos() { # get gist id from index files _gist_id() { GIST_ID=$( (grep -hs '' $INDEX || true) | sed -n -e "/^$1 / p" | cut -d' ' -f2 | sed -E -e 's#.*/##') - if [[ -z "$GIST_ID" ]]; then + if [[ -z $GIST_ID ]]; then echo -e "Not a valid index: \e[31m$1\e[0m" echo Use the index in the first column instead: echo @@ -400,7 +400,7 @@ _goto_gist() { _delete_gist() { read -r -p "Delete gists above? [y/N] " response response=${response,,} - [[ ! "$response" =~ ^(yes|y)$ ]] && return 0 + [[ ! $response =~ ^(yes|y)$ ]] && return 0 for i in "$@"; do _gist_id "$i" @@ -460,7 +460,7 @@ _show_detail() { # set filename/description/permission for a new gist _set_gist() { public=True - while [[ -n "$@" ]]; do case $1 in + while [[ -n $@ ]]; do case $1 in -d | --desc) description="$2" shift; shift;; @@ -484,7 +484,7 @@ _new_file() { tmp_file=$(mktemp) cat > $tmp_file echo -e '\n' > /dev/tty - [[ -z "$1" ]] && read -p 'Type file name: ' filename < /dev/tty + [[ -z $1 ]] && read -p 'Type file name: ' filename < /dev/tty mv $tmp_file /tmp/$filename echo /tmp/$filename } @@ -505,8 +505,8 @@ print(json.dumps({'public': $public, 'files': files_json, 'description': descrip # create a new gist with files _create_gist() { _set_gist "$@" || return 1 - [[ -z "$files" ]] && files=$(_new_file $filename) - [[ -z "$description" ]] && read -p 'Type description: ' description < /dev/tty + [[ -z $files ]] && files=$(_new_file $filename) + [[ -z $description ]] && read -p 'Type description: ' description < /dev/tty echo 'Creating a new gist...' http_data=$(mktemp) @@ -548,7 +548,7 @@ usage() { _apply_config "$@" || exit 1 getConfiguredClient || exit 1 if [[ $init ]]; then _fetch_gists; exit 0; fi -[[ -z "$hint" ]] && hint=true +[[ -z $hint ]] && hint=true case "$1" in "") hint=$hint _show_list ;; -- cgit v1.2.3-70-g09d2