I installed git bash on windows and try to write a few simple script. One thing I could not figure out so far is simple math and comparison. What I need is a random boolean currently:
#!/usr/bin/env bash
condition=$(($(($RANDOM%2)) == 1))
if $condition; then
echo "a"
else
echo "b"
fi
I got command not found. It looks like git bash is missing comparison operators, <,>,==,!=,-eq,-lt,-gt does not work no matter what I try. I found those in all of the examples. Any idea?
conditionvariable is not a command, andiftakes a command as the thing to check. (anubhava's answer enters an arithmetic context, in which you can use an arithmetic operation as a command; you could also do something like, say,if [ "$condition" -eq 1 ]; then, as[is also a command).