Noice!
I use a slightly different coding style -- here's mine, but I don't make anyone drink my kool aid... I prefer $() to back-ticks -- they're easier to distinguish from other quotes and far easier to nest.
I *think* that you could replace
for i in $(echo $BUGS); do
...
with
for i in $BUGS; do
...
Haven't tested my version. Cavat Emptor.
Cheers,
--Barton
#!/bin/bash
if [[ ! -d ~/bugs2check ]]; then
echo "Creating report directory..."
mkdir ~/bugs2check
fi
git checkout master
BRANCH=$(git status | grep "On branch" | cut -f3- -d' ')
if [[ $BRANCH != "master" ]]; then
echo "Handle your commits first."
exit
fi
echo > ~/bugs2check/REPORT
BUGS=$(git branch | grep "bug_[0-9][0-9]*$" | cut -f2 -d'_' | sort -u)
for i in $(echo $BUGS); do
STATUS=`grep static_bug ~/bugs2check/$i | cut -f2 -d'>'`
echo $i - $STATUS | tee -a ~/bugs2check/REPORT
done
for STATUS in 'Pushed to Master' 'Pushed to Stable' 'CLOSED' 'RESOLVED'
do
BUGS2DEL=$(grep "$STATUS" ~/bugs2check/REPORT | cut -f1 -d' ')
for i in $(echo $BUGS2DEL); do
BRANCHES=$(git branch | grep bug_$i)
read -p "Delete $BRANCHES? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
for j in $(echo $BRANCHES); do
git branch -D $j
done
fi
done
done