Skip to content

Commit

Permalink
Handle empty argument in main case block
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusauler committed Jul 25, 2024
1 parent fa91c6f commit d94304c
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions wt
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,32 @@ if echo "${args[@]}" | grep -v update &> /dev/null; then
auto_check_update
fi

if [ -z "${args[0]}" ]; then
case "${args[0]}" in
list)
worktree_list
;;
names)
worktree_list_names
;;
update)
update
;;
help)
help_message
;;
version)
echo Version: $VERSION
;;
init)
init
;;
'')
goto_main_worktree
else
case "${args[0]}" in
list)
worktree_list
;;
names)
worktree_list_names
;;
update)
update
;;
help)
help_message
;;
version)
echo Version: $VERSION
;;
init)
init
;;
*)
directory=$(git worktree list --porcelain | grep -E 'worktree ' | awk '/'"$arg"'/ {print; exit}' | cut -d ' ' -f2-)
;;
esac
fi
;;
*)
directory=$(git worktree list --porcelain | grep -E 'worktree ' | awk '/'"$arg"'/ {print; exit}' | cut -d ' ' -f2-)
;;
esac

# If directory variable is not empty then change worktree
if [ -z "$directory" ]; then
Expand Down

0 comments on commit d94304c

Please sign in to comment.