]> git.phdru.name Git - dotfiles.git/commitdiff
.shellrc: Improve array processing
authorOleg Broytman <phd@phdru.name>
Mon, 5 Aug 2019 14:55:45 +0000 (17:55 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 5 Aug 2019 14:55:45 +0000 (17:55 +0300)
Make `GIT_REMOTES` array instead of converting it
from a string to array.

.shellrc

index 9a484c15d96f836e0362a4004b71128e7e81dfda..3eeb62129e715602183429a0d902a538828d7a19 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -225,14 +225,13 @@ if test -x /usr/bin/git >/dev/null 2>&1; then
          cdgitpath remote.$remote.url
       else
 
-         local GIT_REMOTES remote
-         GIT_REMOTES=""
+         local remote
+         local -a GIT_REMOTES=()
          for remote in `git remote`; do
             if git config --get remote.$remote.url | grep -q '^\(/\|\.\./\)'; then
-               GIT_REMOTES="$GIT_REMOTES $remote"
+               GIT_REMOTES+=($remote)
             fi
          done
-         GIT_REMOTES=($GIT_REMOTES)
          if [ ${#GIT_REMOTES[*]} -eq 1 ]; then
             remote=${GIT_REMOTES[0]}
             cdgitpath remote.$remote.url
@@ -281,11 +280,11 @@ if test -x /usr/bin/git >/dev/null 2>&1; then
             echo "Usage: _list_remotes remote_regexp" >&2
             return 1
          fi
-         GIT_REMOTES=""
+         declare -ag GIT_REMOTES=()
          local remote
          for remote in `git remote`; do
             if git config --get remote.$remote.url | grep -q "$1"; then
-               GIT_REMOTES="$GIT_REMOTES $remote"
+               GIT_REMOTES+=($remote)
             fi
          done
       }