Skip to content

Commit

Permalink
Escape forward slash in search keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
yankeexe committed Mar 19, 2022
1 parent 83c6c1f commit 9806d04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ set -e
# Switch between git worktrees with speed.

args=("$@")
VERSION="0.0.9"
VERSION="0.1.0"
TMP_PATH=$(mktemp)
BINARY_PATH=$(which wt)
JQ_URL="https://stedolan.github.io/jq/download"
RELEASE_URL="https://github.com/yankeexe/git-worktree-switcher/releases/latest"
RELEASE_API_URL="https://api.github.com/repos/yankeexe/git-worktree-switcher/releases/latest"


# Escape forward slash
arg=$(echo "${args[0]}" | sed 's/\//\\\//g')

# show worktree list
worktree_list() {
git worktree list
Expand All @@ -27,7 +31,7 @@ help_message() {
}

goto_main_worktree() {
main_worktree=$(git worktree list --porcelain | awk '{print $0; exit}' | grep -oP '(?<=worktree ).*' )
main_worktree=$(git worktree list --porcelain | awk '{print $0; exit}' | grep -oP '(?<=worktree ).*')

if [ -z "$main_worktree" ]; then
:
Expand Down Expand Up @@ -95,7 +99,7 @@ version)
goto_main_worktree
;;
*)
directory=$(git worktree list --porcelain | awk '/'"${args[0]}"'/ {print; exit}' | grep -oP '(?<=worktree ).*' )
directory=$(git worktree list --porcelain | awk '/'"$arg"'/ {print; exit}' | grep -oP '(?<=worktree ).*')
;;
esac

Expand Down

0 comments on commit 9806d04

Please sign in to comment.