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

     1  # `runmode`
     2  
     3  > Alter the scheduler's behaviour at higher scoping level
     4  
     5  ## Description
     6  
     7  Due to dynamic nature in which blocks are compiled on demand, traditional `try`
     8  and `trypipe` blocks cannot affect the runtime behaviour of schedulers already
     9  invoked (eg for function blocks and modules which `try` et al would sit inside).
    10  To solve this we need an additional command that is executed by the compiler
    11  prior to the block being executed which can define the runmode of the scheduler.
    12  This is the purpose of `runmode`.
    13  
    14  The caveat of being a compiler command rather than a builtin is that `runmode`
    15  needs be the first command in a block.
    16  
    17  ## Usage
    18  
    19  ```
    20  runmode try|trypipe function|module
    21  ```
    22  
    23  ## Examples
    24  
    25  ```
    26  function hello {
    27      # Short conversation, exit on error
    28      
    29      runmode try function
    30  
    31      read name "What is your name? "
    32      out "Hello $name, pleased to meet you"
    33      
    34      read mood "How are you feeling? "
    35      out "I'm feeling $mood too"
    36  }
    37  ```
    38  
    39  ## Detail
    40  
    41  `runmode`'s parameters are ordered:
    42  
    43  ### 1st parameter
    44  
    45  #### unsafe
    46  
    47  Always return a zero exit number.
    48  
    49  #### try
    50  
    51  Checks only the last command in the pipeline for errors. However still allows
    52  commands in a pipeline to run in parallel.
    53  
    54  #### trypipe
    55  
    56  Checks every command in the pipeline before executing the next. However this
    57  blocks pipelines from running every command in parallel.
    58  
    59  #### tryerr
    60  
    61  Checks last command in the pipeline for errors (still allowing commands to run
    62  in parallel) plus also checks if STDERR contains excessive output.
    63  
    64  #### trypipeerr
    65  
    66  Checks every command in the pipeline before executing the next (blocking
    67  commands from running in parallel) plus also checks if STDERR contains
    68  excessive output.
    69  
    70  ### 2nd parameter
    71  
    72  #### function
    73  
    74  Sets the runmode for all blocks within the function when `runmode` is placed at
    75  the start of the function. This includes privates, autocompletes, events, etc.
    76  
    77  #### module
    78  
    79  Sets the runmode for all blocks within that module when placed at the start of
    80  the module. This include any functions, privates, autocompletes, events, etc
    81  that are inside that module. They do not need a separate `runmode ... function`
    82  if `runmode ... module` is set.
    83  
    84  ## See Also
    85  
    86  * [Pipeline](../user-guide/pipeline.md):
    87    Overview of what a "pipeline" is
    88  * [Schedulers](../user-guide/schedulers.md):
    89    Overview of the different schedulers (or 'run modes') in Murex
    90  * [`autocomplete`](../commands/autocomplete.md):
    91    Set definitions for tab-completion in the command line
    92  * [`catch`](../commands/catch.md):
    93    Handles the exception code raised by `try` or `trypipe`
    94  * [`event`](../commands/event.md):
    95    Event driven programming for shell scripts
    96  * [`fid-list`](../commands/fid-list.md):
    97    Lists all running functions within the current Murex session
    98  * [`function`](../commands/function.md):
    99    Define a function block
   100  * [`out`](../commands/out.md):
   101    Print a string to the STDOUT with a trailing new line character
   102  * [`private`](../commands/private.md):
   103    Define a private function block
   104  * [`read`](../commands/read.md):
   105    `read` a line of input from the user and store as a variable
   106  * [`try`](../commands/try.md):
   107    Handles non-zero exits inside a block of code
   108  * [`tryerr`](../commands/tryerr.md):
   109    Handles errors inside a block of code
   110  * [`trypipe`](../commands/trypipe.md):
   111    Checks for non-zero exits of each function in a pipeline
   112  * [`trypipeerr`](../commands/trypipeerr.md):
   113    Checks state of each function in a pipeline and exits block on error
   114  * [`unsafe`](../commands/unsafe.md):
   115    Execute a block of code, always returning a zero exit number
   116  
   117  <hr/>
   118  
   119  This document was generated from [builtins/core/structs/try_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/structs/try_doc.yaml).