cdg asks if multiple solutions are possible
This commit is contained in:
parent
1131871d77
commit
ed3162d200
|
@ -90,16 +90,31 @@ if [ -d "$GCLONE_PATH" ]; then
|
||||||
echo "This function expects a single parameter"
|
echo "This function expects a single parameter"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
dir=`find $GCLONE_PATH -maxdepth 3 -name $1`
|
found_dirs=`find $GCLONE_PATH -maxdepth 3 -name $1 | sort`
|
||||||
|
total=`echo $found_dirs | wc -l`
|
||||||
|
|
||||||
if [[ "" == "$dir" ]]; then
|
if [[ "" == "$found_dirs" ]]; then
|
||||||
echo "$1 not found"
|
echo "$1 not found"
|
||||||
return 2
|
return 2
|
||||||
elif [ `echo $dir | wc -l` -gt 1 ]; then
|
elif [ $total -gt 1 ]; then
|
||||||
echo "Multiple entries for $1 found"
|
counter=0
|
||||||
|
echo "Multiple entries for $1 found:"
|
||||||
|
echo $found_dirs | while read found_dir; do
|
||||||
|
counter=$(($counter+1))
|
||||||
|
echo "["$counter"]" $found_dir
|
||||||
|
done
|
||||||
|
read choice
|
||||||
|
if [[ "$choice" == "" ]]; then
|
||||||
|
cd `echo $found_dirs | head -1 | tail -1`
|
||||||
|
elif [[ "$choice" =~ '^[0-9]+$' ]] && [ $choice -le $total ] && [ $choice -gt 0 ]; then
|
||||||
|
cd `echo $found_dirs | head -$choice | tail -1`
|
||||||
|
else
|
||||||
|
echo "I expected a number that was less than the max..."
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
return 3
|
return 3
|
||||||
else
|
else
|
||||||
cd $dir
|
cd $found_dirs
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue