aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-29 23:37:40 +0800
committertypebrook <typebrook@gmail.com>2020-03-29 23:37:40 +0800
commitf2be2e0ed117559507ac75a6c522b5e6ffdc1395 (patch)
tree27d7daa017a2556c003d78c885442051227d2199
parent0097971689ed84da1cfadebb47392089d93b3338 (diff)
Fix logic error about action
-rwxr-xr-xgist34
1 files changed, 17 insertions, 17 deletions
diff --git a/gist b/gist
index 6564c93..b3ddff2 100755
--- a/gist
+++ b/gist
@@ -464,6 +464,20 @@ _gist_id() {
464 fi 464 fi
465} 465}
466 466
467# Show path of repo by gist ID, and perform action
468_goto_gist() {
469 echo "$folder/$GIST_ID"
470 touch "$folder/$GIST_ID"
471
472 if [[ $@ =~ --no-action ]]; then
473 return 0
474 elif [[ -z $action ]]; then
475 action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}'
476 fi
477
478 cd "$folder/$GIST_ID" && eval "$action"
479}
480
467# Return the path of local repo with a given index 481# Return the path of local repo with a given index
468_goto_gist_by_index() { 482_goto_gist_by_index() {
469 _gist_id "$1" || return 1 483 _gist_id "$1" || return 1
@@ -478,21 +492,7 @@ _goto_gist_by_index() {
478 fi 492 fi
479 fi 493 fi
480 494
481 _goto_gist 495 _goto_gist "$@"
482}
483
484_goto_gist() {
485 echo "$folder/$GIST_ID"
486 touch "$folder/$GIST_ID"
487
488 if [[ -z $action ]]; then
489 action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}'
490 fi
491 if [[ $2 == '--no-action' ]]; then
492 return 0
493 else
494 cd "$folder/$GIST_ID" && eval "$action"
495 fi
496} 496}
497 497
498# Delete gists with given indices 498# Delete gists with given indices
@@ -778,7 +778,7 @@ _gists_with_range() {
778 778
779_access_last_index() { 779_access_last_index() {
780 GIST_ID=$(ls -tup $folder | grep / | head -1) 780 GIST_ID=$(ls -tup $folder | grep / | head -1)
781 _goto_gist 781 _goto_gist "$@"
782} 782}
783 783
784_apply_config "$@" || exit 1 784_apply_config "$@" || exit 1
@@ -838,7 +838,7 @@ case "$1" in
838 *-*) 838 *-*)
839 _gists_with_range "$@" ;; 839 _gists_with_range "$@" ;;
840 last | L) 840 last | L)
841 _access_last_index ;; 841 _access_last_index "$@" ;;
842 version) 842 version)
843 echo "Version $currentVersion" ;; 843 echo "Version $currentVersion" ;;
844 update) 844 update)