I am learning git for some time, recently I have been using aliases. Everything was working, until last time. My example alias stopped working ( git simple-commit works fine )
simple-loop = "!simpleLoop() { NAME=$1; i="1"; while [ $i -le $2 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; }; simpleLoop"
I am getting fatal in terminal
simpleLoop() { NAME=$1; i=1; while [ $i -le $2 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; };
simpleLoop: 1: [: Illegal number: $[1+1]
It looks like git not using bash shell. Any idea what is going on ?
I just tested a simplified version of that alias:
And
git aa
does give the expected result:To be sure, assuming Git for Windows, test your alias in a
CMD
session with a simplifiedPATH
:You can also use a number for
i
(i=1
instead of"1"
) and use other syntax to increment that variable (likei=$((i+1))
)