Q: how to git clone and verify in a single bash line I want to "git clone" + verify in one bash line.
This is what I've tried but it prints the error ("echo" + exit)
[ ! `git clone $1/repo $2/repo` ] && echo "clone failed from $1/repo to $2/repo" && exit 30

The clone work but the error is printed too.
2 lines solution works but I wonder what might be the problem
git clone $1/repo $2/repo
[[ "$?" != "0" ]] && echo "clone failed from $1/repo to $2/repo" && exit 30


I have also noticed this line is not working (might be a similar problem):
[ ! `ls -a` ] && echo "aaa"

with error

bash: [: too many arguments

but this one does:
[ ! `ls -d` ] && echo "aaa"


A: Why do you put the first command into backquotes? It returns its output, but you want to check its exit code. No square brackets are needed for that:
git clone "$1"/repo "$2"/repo || { echo 'Clone failed' ; exit 30 ; }


A: Well it a bit pessimistic way but it works
! git clone $1/repo $2/repo && echo "clone failed from $1/repo to $2/repo" && exit 30

I am not entirely sure but when there is an output from the command, the outer bash is probably trying to execute it and that what actually fails.
