How to update or clone hg in one bash line?

I am looking for an opportunity to make an hg update in the repository or to clone it if it does not exist. Thus, the team should fail only if something went wrong (cloning or updating).

This should work in bash, preferably if you already configured it set -e.

+3
source share
2 answers

The disjunction operator in bash ||can execute this scenario: try executing the first command if the second command fails, if it fails to return the error code. Specifically for this question,

hg update || hg clone <source>

; , . , .

, .

?

>/dev/null; 2>/dev/null; .

+6
cd <directory> && hg update || hg clone <source>

cd , , hg .

+3

All Articles