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

     1  # `exec`
     2  
     3  > Runs an executable
     4  
     5  ## Description
     6  
     7  With Murex, like most other shells, you launch a process by calling the
     8  name of that executable directly. While this is suitable 99% of the time,
     9  occasionally you might run into an edge case where that wouldn't work. The
    10  primary reason being if you needed to launch a process from a variable, eg
    11  
    12  ```
    13  » set exe=uname
    14  » $exe
    15  uname
    16  ```
    17  
    18  As you can see here, Murex's behavior here is to output the contents of
    19  the variable rather then executing the contents of the variable. This is
    20  done for safety reasons, however if you wanted to override that behavior
    21  then you could prefix the variable with exec:
    22  
    23  ```
    24  » set exe=uname
    25  » exec $exe
    26  Linux
    27  ```
    28  
    29  ## Usage
    30  
    31  ```
    32  <stdin> -> exec
    33  <stdin> -> exec -> <stdout>
    34             exec -> <stdout>
    35  ```
    36  
    37  ## Examples
    38  
    39  ```
    40  » exec printf "Hello, world!"
    41  Hello, world!
    42  ```
    43  
    44  **Working around aliases:**
    45  
    46  If you have an alias like `alias ls=ls --color=auto` and you wanted to run `ls`
    47  but without colour, you might run `exec ls`.
    48  
    49  ## Detail
    50  
    51  If any command doesn't exist as a builtin, function nor alias, then Murex
    52  will default to forking out to any command with this name (subject to an
    53  absolute path or the order of precedence in `$PATH`). Any forked process will
    54  show up in both the operating systems process viewer (eg `ps`) but also
    55  Murex's own process viewer, `fid-list`. However inside `fid-list` you will
    56  notice that all external processes are listed as `exec` with the process name
    57  as part of `exec`'s parameters. That is because `exec` is handler for programs
    58  that aren't native to Murex.
    59  
    60  ### Compatibility with POSIX
    61  
    62  For compatibility with traditional shells like Bash and Zsh, `command` is an
    63  alias for `exec`.
    64  
    65  ## Synonyms
    66  
    67  * `exec`
    68  * `command`
    69  
    70  
    71  ## See Also
    72  
    73  * [`bexists`](../commands/bexists.md):
    74    Check which builtins exist
    75  * [`bg`](../commands/bg.md):
    76    Run processes in the background
    77  * [`builtins`](../commands/runtime.md):
    78    Returns runtime information on the internal state of Murex
    79  * [`fexec` ](../commands/fexec.md):
    80    Execute a command or function, bypassing the usual order of precedence.
    81  * [`fg`](../commands/fg.md):
    82    Sends a background process into the foreground
    83  * [`fid-kill`](../commands/fid-kill.md):
    84    Terminate a running Murex function
    85  * [`fid-killall`](../commands/fid-killall.md):
    86    Terminate _all_ running Murex functions
    87  * [`fid-list`](../commands/fid-list.md):
    88    Lists all running functions within the current Murex session
    89  * [`jobs`](../commands/fid-list.md):
    90    Lists all running functions within the current Murex session
    91  * [`murex-update-exe-list`](../commands/murex-update-exe-list.md):
    92    Forces Murex to rescan $PATH looking for executables
    93  * [`set`](../commands/set.md):
    94    Define a local variable and set it's value
    95  
    96  <hr/>
    97  
    98  This document was generated from [builtins/core/typemgmt/types_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/typemgmt/types_doc.yaml).