Clone all Repos from a Bitbucket source

I have about 22 repositories on bitbucket and downloading them can be a pain. Here’s a short script to make life easier:

#!/bin/bash
#Script to get all repositories under a user from bitbucket
#Usage: getAllRepos.sh [username]

curl -u ${1}  https://api.bitbucket.org/1.0/users/${1} > repoinfo
for repo_name in `grep \"name\" repoinfo | cut -f4 -d\"`
do
	hg clone ssh://hg@bitbucket.org/${1}/$repo_name
done

UPDATE: Corrected a typo. Many thanks to fr3d3r1cbaz1n for pointing it out! Also, as fr3d3r1cbaz1n noted, this script only works for Mercurial but git users can easily change the hg command to git.