- Oct
- 3
- 0
I am converting some Bash scripts that I wrote to BTM.
One of the problems was to make sure that, whenever an external command returns a non-zero return code, the script should stop and say something meaningful.
This is what I have produced, please tell me if there is a better way.
One of the problems was to make sure that, whenever an external command returns a non-zero return code, the script should stop and say something meaningful.
This is what I have produced, please tell me if there is a better way.
Code:
@echo off
setlocal
alias Usage `echo Usage: downloadrepo.btm package & quit 1`
alias MustSucceed `%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 & IF "%ERRORLEVEL%" NE "0" ( echo Error in %1 & quit 2 )`
IF "%1" EQ "" .OR. "%2" NE "" Usage
mkdir %1
cd %1
MustSucceed git init
MustSucceed git remote add cc "[email protected]:/var/git/%1.git"
MustSucceed git pull cc master --tags