#!/bin/bash -e

# look for directories which respond to `git branch' command.

git_duplicates=0
git_branches=0
git_count=0
git_bad=0
git_dirs=$(find ${HOME} -name '.git')

for dir in $git_dirs; do
    dir=${dir%.git}

    if [[ $@ == *"-l"* ]] || [[ $@ == "--list" ]]; then
        echo $dir
    fi

    # XXX Returns single line, with variable spacing
    branches=$(git -C $dir branch 2> /dev/null) || continue

    IFS=$'\n'
    for branch in "${branches}"; do
        let ++git_branches
    done

    let ++git_count

done

printf "gits:%d, duplicates:%d, branches:%d\n" $git_count $git_duplicates $git_branches


#!/bin/bash -e

# look for directories which respond to `git branch' command.

git_duplicates=0
git_branches=0
git_count=0
git_bad=0
git_dirs=$(find ${HOME} -name '.git')

for dir in $git_dirs; do
    dir=${dir%.git}

    if [[ $@ == *"-l"* ]]; then
        echo $dir
    fi

    # XXX Returns single line, with variable spacing
    branches=$(git -C $dir branch 2> /dev/null) || continue

    IFS=$'\n'
    for branch in "${branches}"; do
        let ++git_branches
    done

    let ++git_count

done

printf "gits:%d, duplicates:%d, branches:%d\n" $git_count $git_duplicates $git_branches


--- 
+++ 
@@ -11,7 +11,7 @@
 for dir in $git_dirs; do
     dir=${dir%.git}
 
-    if [[ $@ == *"-l"* ]]; then
+    if [[ $@ == *"-l"* ]] || [[ $@ == "--list" ]]; then
         echo $dir
     fi
 
Add check for long form flag
