this means you need to write everything separate, test doesn't parse, plus it needs the closing bracket if you use the alias
but if-then works with any expression, and you put ; after expressions
if test 1 -eq 2 ; then echo "oh noes" ; fiI'll make sure to either use test or [[ and never [ again so that I remember the difference. And I am currently reading man test
(I continue to use [[ and never look back, just forward, trying to picture the shining city on a conveniently sloped hill, where people live without fear in their hearts, where they have compile time checking for their scripts, and the compiler gently pushes them toward sane error handling. Not too much, but definitely not too little. Something like Rust's Result type.)
2
> Do I use == or -eq?
For string comparison, use '='. For arithmetic comparison, use -eq, -gt, -lt, etc.
> Where does the semicolon go again?
Whenever you're putting multiple lines on one. If you use multiple lines, you don't need semicolons.
For example:
if [[ "$result" = 'SUCCESS' ]] && [[ "$count" -gt 0 ]]
then
echo 'Hooray!'
fiIf you want a much-reduced version, read man dash instead. It is very small and close to POSIX semantics. You can then later go find the Bashisms.
Some code style guides for Linux distros or work places like Google actually enforce this!