github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/or.md (about)

     1  # `or`
     2  
     3  > Returns `true` or `false` depending on whether one code-block out of multiple ones supplied is successful or unsuccessful.
     4  
     5  ## Description
     6  
     7  Returns a boolean results (`true` or `false`) depending on whether any of the
     8  code-blocks included as parameters are successful or not.
     9  
    10  ## Usage
    11  
    12  ```
    13  or { code-block } { code-block } -> <stdout>
    14  
    15  !or { code-block } { code-block } -> <stdout>
    16  ```
    17  
    18  `or` supports as many or as few code-blocks as you wish.
    19  
    20  ## Examples
    21  
    22  ```
    23  if { or { = 1+1==2 } { = 2+2==5 } { = 3+3==6 } } then {
    24      out At least one of those equations are correct
    25  }
    26  ```
    27  
    28  ## Detail
    29  
    30  `or` does not set the exit number on failure so it is safe to use inside a `try`
    31  or `trypipe` block.
    32  
    33  If `or` is prefixed by a bang (`!or`) then it returns `true` when one or more
    34  code-blocks are unsuccessful (ie the opposite of `or`).
    35  
    36  ### Code-Block Testing
    37  
    38  * `or` only executes code-blocks up until one of the code-blocks is successful
    39    then it exits the function and returns `true`.
    40  
    41  * `!or` only executes code-blocks while the code-blocks are successful. Once one
    42    is unsuccessful `!or` exits and returns `true` (ie it `not`s every code-block).
    43  
    44  ## Synonyms
    45  
    46  * `or`
    47  * `!or`
    48  
    49  
    50  ## See Also
    51  
    52  * [`!` (not)](../parser/not-func.md):
    53    Reads the STDIN and exit number from previous process and not's it's condition
    54  * [`and`](../commands/and.md):
    55    Returns `true` or `false` depending on whether multiple conditions are met
    56  * [`catch`](../commands/catch.md):
    57    Handles the exception code raised by `try` or `trypipe`
    58  * [`false`](../commands/false.md):
    59    Returns a `false` value
    60  * [`if`](../commands/if.md):
    61    Conditional statement to execute different blocks of code depending on the result of the condition
    62  * [`true`](../commands/true.md):
    63    Returns a `true` value
    64  * [`try`](../commands/try.md):
    65    Handles non-zero exits inside a block of code
    66  * [`trypipe`](../commands/trypipe.md):
    67    Checks for non-zero exits of each function in a pipeline
    68  
    69  <hr/>
    70  
    71  This document was generated from [builtins/core/structs/andor_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/andor_doc.yaml).