I am trying to automate some of my interactions with git using bash scripts. To do so I have a script that will ssh and list all the repositories and then clone them. Part of the script is shown here
DIRS=`ssh $u "ls $p"`;
for DIR in $DIRS; do
echo "ssh://$u$p$DIR"
echo "git clone ssh://$u$p$DIR";
git clone ssh://$u$p$DIR
done
Example arguments are
-u user@host
and
-p /cygdrive/c/Documents\ and\ Settings/somePath
This work fine for filepaths with spaces in their names up until the git clone part where it throws an error about too many spaces. If I copy and pasted the part echoed by
echo "git clone ssh://$u$p$DIR";
then it clones just fine. I have tried to surround this in quotes but it throws an error
does not appear to be a git repository
What am I doing wrong?
Edit 1
The errors when using git clone "ssh://$u$p$DIR"
is
fatal: '/cygdrive/c/Documents\ and\ Settings/somePath/repo1' does not appear to be a git repository
fatal: The remote end hung up unexpectedly