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

     1  # `trypipe`
     2  
     3  > Checks for non-zero exits of each function in a pipeline
     4  
     5  ## Description
     6  
     7  `trypipe` checks the state of each function and exits the block if any of them
     8  fail. Where `trypipe` differs from regular `try` blocks is `trypipe` will check
     9  every process along the pipeline as well as the terminating function (which
    10  `try` only validates against). The downside to this is that piped functions can
    11  no longer run in parallel.
    12  
    13  ## Usage
    14  
    15  ```
    16  trypipe { code-block } -> <stdout>
    17  
    18  <stdin> -> trypipe { -> code-block } -> <stdout>
    19  ```
    20  
    21  ## Examples
    22  
    23  ```
    24  trypipe {
    25      out "Hello, World!" -> grep: "non-existent string" -> cat
    26      out "This command will be ignored"
    27  }
    28  ```
    29  
    30  Formated pager (`less`) where the pager isn't called if the formatter (`pretty`) fails (eg input isn't valid JSON):
    31  
    32  ```
    33  func pless {
    34      -> trypipe { -> pretty -> less }
    35  }
    36  ```
    37  
    38  ## Detail
    39  
    40  A failure is determined by:
    41  
    42  * Any process that returns a non-zero exit number
    43  
    44  You can see which run mode your functions are executing under via the `fid-list`
    45  command.
    46  
    47  ## See Also
    48  
    49  * [Schedulers](../user-guide/schedulers.md):
    50    Overview of the different schedulers (or 'run modes') in Murex
    51  * [`catch`](../commands/catch.md):
    52    Handles the exception code raised by `try` or `trypipe`
    53  * [`fid-list`](../commands/fid-list.md):
    54    Lists all running functions within the current Murex session
    55  * [`if`](../commands/if.md):
    56    Conditional statement to execute different blocks of code depending on the result of the condition
    57  * [`runmode`](../commands/runmode.md):
    58    Alter the scheduler's behaviour at higher scoping level
    59  * [`switch`](../commands/switch.md):
    60    Blocks of cascading conditionals
    61  * [`try`](../commands/try.md):
    62    Handles non-zero exits inside a block of code
    63  * [`tryerr`](../commands/tryerr.md):
    64    Handles errors inside a block of code
    65  * [`trypipeerr`](../commands/trypipeerr.md):
    66    Checks state of each function in a pipeline and exits block on error
    67  * [`unsafe`](../commands/unsafe.md):
    68    Execute a block of code, always returning a zero exit number
    69  
    70  <hr/>
    71  
    72  This document was generated from [builtins/core/structs/try_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/try_doc.yaml).