Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: if (()){}else{} documented?




On 20/04/2021 16:19, Marc Chantreux wrote:

not appear at the very begin of an expression but all the rest is ok.

meaning those are correct

      if (( $1 == 4 )) { echo good } else { echo bad }

      if (( $1 == 4 )) {
          echo good
      } else {
          echo bad
      }

this is not

      if (( $1 == 4 )) {
          echo good
      }
      else {
          echo bad
      }

This is very helpful & clarifies. I 'd forgotten that shells are more strict in their response to 'white space' than programming languages .

While playing golf I've noticed that the  'else' clause is particularly intolerant it needs '} else {'





Messages sorted by: Reverse Date, Date, Thread, Author