github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/user-guide/README.md (about)

     1  <h1>User Guide</h1>
     2  
     3  This section contains miscellaneous documents on using and configuring the
     4  shell and Murex's numerous features.
     5  
     6  <h2>Table of Contents</h2>
     7  
     8  <div id="toc">
     9  
    10  - [Language Tour](#language-tour)
    11  - [User Guides](#user-guides)
    12  - [Builtin Commands](#builtin-commands)
    13    - [Standard Builtins](#standard-builtins)
    14    - [Optional Builtins](#optional-builtins)
    15  - [Data Types](#data-types)
    16  - [Events](#events)
    17  - [API Reference](#api-reference)
    18  
    19  </div>
    20  
    21  ## Language Tour
    22  
    23  The [Language Tour](/tour.md) is a great introduction into the Murex language.
    24  
    25  ## User Guides
    26  
    27  * [ANSI Constants](../user-guide/ansi.md):
    28    Infixed constants that return ANSI escape sequences
    29  * [Bang Prefix](../user-guide/bang-prefix.md):
    30    Bang prefixing to reverse default actions
    31  * [Code Block Parsing](../user-guide/code-block.md):
    32    Overview of how code blocks are parsed
    33  * [FileRef](../user-guide/fileref.md):
    34    How to track what code was loaded and from where
    35  * [Interactive Shell](../user-guide/interactive-shell.md):
    36    What's different about Murex's interactive shell?
    37  * [Job Control](../user-guide/job-control.md):
    38    How to manage jobs with Murex
    39  * [Modules and Packages](../user-guide/modules.md):
    40    An introduction to Murex modules and packages
    41  * [Named Pipes](../user-guide/namedpipes.md):
    42    A detailed breakdown of named pipes in Murex
    43  * [Pipeline](../user-guide/pipeline.md):
    44    Overview of what a "pipeline" is
    45  * [Profile Files](../user-guide/profile.md):
    46    A breakdown of the different files loaded on start up
    47  * [Reserved Variables](../user-guide/reserved-vars.md):
    48    Special variables reserved by Murex
    49  * [Rosetta Stone](../user-guide/rosetta-stone.md):
    50    A tabulated list of Bashism's and their equivalent Murex syntax
    51  * [Schedulers](../user-guide/schedulers.md):
    52    Overview of the different schedulers (or 'run modes') in Murex
    53  * [Spellcheck](../user-guide/spellcheck.md):
    54    How to enable inline spellchecking
    55  * [Terminal Hotkeys](../user-guide/terminal-keys.md):
    56    A list of all the terminal hotkeys and their uses
    57  * [Variable and Config Scoping](../user-guide/scoping.md):
    58    How scoping works within Murex
    59  
    60  ## Operators And Tokens
    61  
    62  * [Array (`@`) Token](parser/array.md):
    63    Expand values as an array
    64  * [Tilde (`~`) Token](parser/tilde.md):
    65    Home directory path variable
    66  * [`!` (not)](parser/not-func.md):
    67    Reads the STDIN and exit number from previous process and not's it's condition
    68  * [`"Double Quote"`](parser/double-quote.md):
    69    Initiates or terminates a string (variables expanded)
    70  * [`$Variable`](parser/scalar.md):
    71    Expand values as a scalar
    72  * [`%(Brace Quote)`](parser/brace-quote.md):
    73    Initiates or terminates a string (variables expanded)
    74  * [`%[]` Create Array](parser/create-array.md):
    75    Quickly generate arrays
    76  * [`%{}` Create Map](parser/create-object.md):
    77    Quickly generate objects and maps
    78  * [`&&` And Logical Operator](parser/logical-and.md):
    79    Continues next operation if previous operation passes
    80  * [`'Single Quote'`](parser/single-quote.md):
    81    Initiates or terminates a string (variables not expanded)
    82  * [`(brace quote)`](parser/brace-quote-func.md):
    83    Write a string to the STDOUT without new line (deprecated)
    84  * [`*=` Multiply By Operator](parser/multiply-by.md):
    85    Multiplies a variable by the right hand value (expression)
    86  * [`*` Multiplication Operator](parser/multiplication.md):
    87    Multiplies one numeric value with another (expression)
    88  * [`+=` Add With Operator](parser/add-with.md):
    89    Adds the right hand value to a variable (expression)
    90  * [`+` Addition Operator](parser/addition.md):
    91    Adds two numeric values together (expression)
    92  * [`-=` Subtract By Operator](parser/subtract-by.md):
    93    Subtracts a variable by the right hand value (expression)
    94  * [`->` Arrow Pipe](parser/pipe-arrow.md):
    95    Pipes STDOUT from the left hand command to STDIN of the right hand command
    96  * [`-` Subtraction Operator](parser/subtraction.md):
    97    Subtracts one numeric value from another (expression)
    98  * [`/=` Divide By Operator](parser/divide-by.md):
    99    Divides a variable by the right hand value (expression)
   100  * [`/` Division Operator](parser/division.md):
   101    Divides one numeric value from another (expression)
   102  * [`<read-named-pipe>`](parser/namedpipe.md):
   103    Reads from a Murex named pipe
   104  * [`=>` Generic Pipe](parser/pipe-generic.md):
   105    Pipes a reformatted STDOUT stream from the left hand command to STDIN of the right hand command
   106  * [`=` (arithmetic evaluation)](parser/equ.md):
   107    Evaluate a mathematical function (deprecated)
   108  * [`>>` Append File](parser/greater-than-greater-than.md):
   109    Writes STDIN to disk - appending contents if file already exists
   110  * [`>>` Append Pipe](parser/pipe-append.md):
   111    Redirects STDOUT to a file and append its contents
   112  * [`?:` Elvis Operator](parser/elvis.md):
   113    Returns the right operand if the left operand is falsy (expression)
   114  * [`??` Null Coalescing Operator](parser/null-coalescing.md):
   115    Returns the right operand if the left operand is empty / undefined (expression)
   116  * [`?` STDERR Pipe](parser/pipe-err.md):
   117    Pipes STDERR from the left hand command to STDIN of the right hand command (DEPRECATED)
   118  * [`[ ..Range ]`](parser/range.md):
   119    Outputs a ranged subset of data from STDIN
   120  * [`[ Index ]`](parser/item-index.md):
   121    Outputs an element from an array, map or table
   122  * [`[[ Element ]]`](parser/element.md):
   123    Outputs an element from a nested structure
   124  * [`[{ Lambda }]`](parser/lambda.md):
   125    Iterate through structured data
   126  * [`{ Curly Brace }`](parser/curly-brace.md):
   127    Initiates or terminates a code block
   128  * [`|>` Truncate File](parser/greater-than.md):
   129    Writes STDIN to disk - overwriting contents if file already exists
   130  * [`|` POSIX Pipe](parser/pipe-posix.md):
   131    Pipes STDOUT from the left hand command to STDIN of the right hand command
   132  * [`||` Or Logical Operator](parser/logical-or.md):
   133    Continues next operation only if previous operation fails
   134  
   135  ## Builtin Commands
   136  
   137  ### Standard Builtins
   138  
   139  * [`2darray` ](../commands/2darray.md):
   140    Create a 2D JSON array from multiple input sources
   141  * [`<stdin>`](../commands/stdin.md):
   142    Read the STDIN belonging to the parent code block
   143  * [`@g` (autoglob) ](../commands/autoglob.md):
   144    Command prefix to expand globbing (deprecated)
   145  * [`a` (mkarray)](../commands/a.md):
   146    A sophisticated yet simple way to build an array or list
   147  * [`addheading` ](../commands/addheading.md):
   148    Adds headings to a table
   149  * [`alias`](../commands/alias.md):
   150    Create an alias for a command
   151  * [`alter`](../commands/alter.md):
   152    Change a value within a structured data-type and pass that change along the pipeline without altering the original source input
   153  * [`and`](../commands/and.md):
   154    Returns `true` or `false` depending on whether multiple conditions are met
   155  * [`append`](../commands/append.md):
   156    Add data to the end of an array
   157  * [`args` ](../commands/args.md):
   158    Command line flag parser for Murex shell scripting
   159  * [`autocomplete`](../commands/autocomplete.md):
   160    Set definitions for tab-completion in the command line
   161  * [`bexists`](../commands/bexists.md):
   162    Check which builtins exist
   163  * [`bg`](../commands/bg.md):
   164    Run processes in the background
   165  * [`break`](../commands/break.md):
   166    Terminate execution of a block within your processes scope
   167  * [`cast`](../commands/cast.md):
   168    Alters the data type of the previous function without altering it's output
   169  * [`catch`](../commands/catch.md):
   170    Handles the exception code raised by `try` or `trypipe`
   171  * [`cd`](../commands/cd.md):
   172    Change (working) directory
   173  * [`config`](../commands/config.md):
   174    Query or define Murex runtime settings
   175  * [`continue`](../commands/continue.md):
   176    Terminate process of a block within a caller function
   177  * [`count`](../commands/count.md):
   178    Count items in a map, list or array
   179  * [`cpuarch`](../commands/cpuarch.md):
   180    Output the hosts CPU architecture
   181  * [`cpucount`](../commands/cpucount.md):
   182    Output the number of CPU cores available on your host
   183  * [`datetime`](../commands/datetime.md):
   184    A date and/or time conversion tool (like `printf` but for date and time values)
   185  * [`debug`](../commands/debug.md):
   186    Debugging information
   187  * [`die`](../commands/die.md):
   188    Terminate murex with an exit number of 1
   189  * [`err`](../commands/err.md):
   190    Print a line to the STDERR
   191  * [`escape`](../commands/escape.md):
   192    Escape or unescape input
   193  * [`esccli`](../commands/esccli.md):
   194    Escapes an array so output is valid shell code
   195  * [`eschtml`](../commands/eschtml.md):
   196    Encode or decodes text for HTML
   197  * [`escurl`](../commands/escurl.md):
   198    Encode or decodes text for the URL
   199  * [`event`](../commands/event.md):
   200    Event driven programming for shell scripts
   201  * [`exec`](../commands/exec.md):
   202    Runs an executable
   203  * [`exit`](../commands/exit.md):
   204    Exit murex
   205  * [`exitnum`](../commands/exitnum.md):
   206    Output the exit number of the previous process
   207  * [`export`](../commands/export.md):
   208    Define an environmental variable and set it's value
   209  * [`expr`](../commands/expr.md):
   210    Expressions: mathematical, string comparisons, logical operators
   211  * [`f`](../commands/f.md):
   212    Lists or filters file system objects (eg files)
   213  * [`false`](../commands/false.md):
   214    Returns a `false` value
   215  * [`fexec` ](../commands/fexec.md):
   216    Execute a command or function, bypassing the usual order of precedence.
   217  * [`fg`](../commands/fg.md):
   218    Sends a background process into the foreground
   219  * [`fid-kill`](../commands/fid-kill.md):
   220    Terminate a running Murex function
   221  * [`fid-killall`](../commands/fid-killall.md):
   222    Terminate _all_ running Murex functions
   223  * [`fid-list`](../commands/fid-list.md):
   224    Lists all running functions within the current Murex session
   225  * [`for`](../commands/for.md):
   226    A more familiar iteration loop to existing developers
   227  * [`foreach`](../commands/foreach.md):
   228    Iterate through an array
   229  * [`formap`](../commands/formap.md):
   230    Iterate through a map or other collection of data
   231  * [`format`](../commands/format.md):
   232    Reformat one data-type into another data-type
   233  * [`function`](../commands/function.md):
   234    Define a function block
   235  * [`g`](../commands/g.md):
   236    Glob pattern matching for file system objects (eg `*.txt`)
   237  * [`get-type`](../commands/get-type.md):
   238    Returns the data-type of a variable or pipe
   239  * [`get`](../commands/get.md):
   240    Makes a standard HTTP request and returns the result as a JSON object
   241  * [`getfile`](../commands/getfile.md):
   242    Makes a standard HTTP request and return the contents as Murex-aware data type for passing along Murex pipelines.
   243  * [`global`](../commands/global.md):
   244    Define a global variable and set it's value
   245  * [`history`](../commands/history.md):
   246    Outputs murex's command history
   247  * [`if`](../commands/if.md):
   248    Conditional statement to execute different blocks of code depending on the result of the condition
   249  * [`is-null`](../commands/is-null.md):
   250    Checks if a variable is null or undefined
   251  * [`ja` (mkarray)](../commands/ja.md):
   252    A sophisticated yet simply way to build a JSON array
   253  * [`jsplit` ](../commands/jsplit.md):
   254    Splits STDIN into a JSON array based on a regex parameter
   255  * [`left`](../commands/left.md):
   256    Left substring every item in a list
   257  * [`let`](../commands/let.md):
   258    Evaluate a mathematical function and assign to variable (deprecated)
   259  * [`lockfile`](../commands/lockfile.md):
   260    Create and manage lock files
   261  * [`man-get-flags` ](../commands/man-get-flags.md):
   262    Parses man page files for command line flags 
   263  * [`man-summary`](../commands/man-summary.md):
   264    Outputs a man page summary of a command
   265  * [`map`](../commands/map.md):
   266    Creates a map from two data sources
   267  * [`match`](../commands/match.md):
   268    Match an exact value in an array
   269  * [`method`](../commands/method.md):
   270    Define a methods supported data-types
   271  * [`msort`](../commands/msort.md):
   272    Sorts an array - data type agnostic
   273  * [`mtac`](../commands/mtac.md):
   274    Reverse the order of an array
   275  * [`murex-docs`](../commands/murex-docs.md):
   276    Displays the man pages for Murex builtins
   277  * [`murex-package`](../commands/murex-package.md):
   278    Murex's package manager
   279  * [`murex-parser` ](../commands/murex-parser.md):
   280    Runs the Murex parser against a block of code 
   281  * [`murex-update-exe-list`](../commands/murex-update-exe-list.md):
   282    Forces Murex to rescan $PATH looking for executables
   283  * [`null`](../commands/devnull.md):
   284    null function. Similar to /dev/null
   285  * [`open-image`](../commands/open-image.md):
   286    Renders bitmap image data on your terminal
   287  * [`open`](../commands/open.md):
   288    Open a file with a preferred handler
   289  * [`openagent`](../commands/openagent.md):
   290    Creates a handler function for `open`
   291  * [`or`](../commands/or.md):
   292    Returns `true` or `false` depending on whether one code-block out of multiple ones supplied is successful or unsuccessful.
   293  * [`os`](../commands/os.md):
   294    Output the auto-detected OS name
   295  * [`out`](../commands/out.md):
   296    Print a string to the STDOUT with a trailing new line character
   297  * [`pipe`](../commands/pipe.md):
   298    Manage Murex named pipes
   299  * [`post`](../commands/post.md):
   300    HTTP POST request with a JSON-parsable return
   301  * [`prefix`](../commands/prefix.md):
   302    Prefix a string to every item in a list
   303  * [`prepend`](../commands/prepend.md):
   304    Add data to the start of an array
   305  * [`pretty`](../commands/pretty.md):
   306    Prettifies JSON to make it human readable
   307  * [`private`](../commands/private.md):
   308    Define a private function block
   309  * [`pt`](../commands/pt.md):
   310    Pipe telemetry. Writes data-types and bytes written
   311  * [`rand`](../commands/rand.md):
   312    Random field generator
   313  * [`read`](../commands/read.md):
   314    `read` a line of input from the user and store as a variable
   315  * [`regexp`](../commands/regexp.md):
   316    Regexp tools for arrays / lists of strings
   317  * [`return`](../commands/return.md):
   318    Exits current function scope
   319  * [`right`](../commands/right.md):
   320    Right substring every item in a list
   321  * [`round`](../commands/round.md):
   322    Round a number by a user defined precision
   323  * [`runmode`](../commands/runmode.md):
   324    Alter the scheduler's behaviour at higher scoping level
   325  * [`runtime`](../commands/runtime.md):
   326    Returns runtime information on the internal state of Murex
   327  * [`rx`](../commands/rx.md):
   328    Regexp pattern matching for file system objects (eg `.*\\.txt`)
   329  * [`set`](../commands/set.md):
   330    Define a local variable and set it's value
   331  * [`signal`](../commands/signal.md):
   332    Sends a signal RPC
   333  * [`source`](../commands/source.md):
   334    Import Murex code from another file of code block
   335  * [`struct-keys`](../commands/struct-keys.md):
   336    Outputs all the keys in a structure as a file path
   337  * [`suffix`](../commands/suffix.md):
   338    Prefix a string to every item in a list
   339  * [`summary` ](../commands/summary.md):
   340    Defines a summary help text for a command
   341  * [`switch`](../commands/switch.md):
   342    Blocks of cascading conditionals
   343  * [`ta` (mkarray)](../commands/ta.md):
   344    A sophisticated yet simple way to build an array of a user defined data-type
   345  * [`tabulate`](../commands/tabulate.md):
   346    Table transformation tools
   347  * [`test`](../commands/test.md):
   348    Murex's test framework - define tests, run tests and debug shell scripts
   349  * [`time`](../commands/time.md):
   350    Returns the execution run time of a command or block
   351  * [`tmp`](../commands/tmp.md):
   352    Create a temporary file and write to it
   353  * [`tout`](../commands/tout.md):
   354    Print a string to the STDOUT and set it's data-type
   355  * [`tread`](../commands/tread.md):
   356    `read` a line of input from the user and store as a user defined *typed* variable (deprecated)
   357  * [`true`](../commands/true.md):
   358    Returns a `true` value
   359  * [`try`](../commands/try.md):
   360    Handles non-zero exits inside a block of code
   361  * [`tryerr`](../commands/tryerr.md):
   362    Handles errors inside a block of code
   363  * [`trypipe`](../commands/trypipe.md):
   364    Checks for non-zero exits of each function in a pipeline
   365  * [`trypipeerr`](../commands/trypipeerr.md):
   366    Checks state of each function in a pipeline and exits block on error
   367  * [`type`](../commands/type.md):
   368    Command type (function, builtin, alias, etc)
   369  * [`unsafe`](../commands/unsafe.md):
   370    Execute a block of code, always returning a zero exit number
   371  * [`version`](../commands/version.md):
   372    Get Murex version
   373  * [`which`](../commands/which.md):
   374    Locate command origin
   375  * [`while`](../commands/while.md):
   376    Loop until condition false
   377  
   378  ### Optional Builtins
   379  
   380  These builtins are optional. `select` is included as part of the default build
   381  but can be disabled without breaking functionality. The other optional builtins
   382  are only included by default on Windows.
   383  
   384  * [`!bz2`](../optional/bz2.md):
   385    Decompress a bz2 file
   386  * [`base64` ](../optional/base64.md):
   387    Encode or decode a base64 string
   388  * [`gz`](../optional/gz.md):
   389    Compress or decompress a gzip file
   390  * [`qr`](../optional/qr.md):
   391    Creates a QR code from STDIN
   392  * [`select`](../optional/select.md):
   393    Inlining SQL into shell pipelines
   394  * [`sleep`](../optional/sleep.md):
   395    Suspends the shell for a number of seconds
   396  
   397  ## Data Types
   398  
   399  * [`*` (generic)](../types/generic.md):
   400    generic (primitive)
   401  * [`bool`](../types/bool.md):
   402    Boolean (primitive)
   403  * [`commonlog`](../types/commonlog.md):
   404    Apache httpd "common" log format
   405  * [`csv`](../types/csv.md):
   406    CSV files (and other character delimited tables)
   407  * [`float` (floating point number)](../types/float.md):
   408    Floating point number (primitive)
   409  * [`hcl`](../types/hcl.md):
   410    HashiCorp Configuration Language (HCL)
   411  * [`int`](../types/int.md):
   412    Whole number (primitive)
   413  * [`json`](../types/json.md):
   414    JavaScript Object Notation (JSON)
   415  * [`jsonc`](../types/jsonc.md):
   416    Concatenated JSON
   417  * [`jsonl`](../types/jsonl.md):
   418    JSON Lines
   419  * [`num` (number)](../types/num.md):
   420    Floating point number (primitive)
   421  * [`path`](../types/path.md):
   422    Structured object for working with file and directory paths
   423  * [`paths`](../types/paths.md):
   424    Structured array for working with `$PATH` style data
   425  * [`str` (string)](../types/str.md):
   426    string (primitive)
   427  * [`toml`](../types/toml.md):
   428    Tom's Obvious, Minimal Language (TOML)
   429  * [`yaml`](../types/yaml.md):
   430    YAML Ain't Markup Language (YAML)
   431  * [mxjson](../types/mxjson.md):
   432    Murex-flavoured JSON (deprecated)
   433  
   434  ## Events
   435  
   436  * [`onCommandCompletion`](../events/oncommandcompletion.md):
   437    Trigger an event upon a command's completion
   438  * [`onFileSystemChange`](../events/onfilesystemchange.md):
   439    Add a filesystem watch
   440  * [`onPrompt`](../events/onprompt.md):
   441    Events triggered by changes in state of the interactive shell
   442  * [`onSecondsElapsed`](../events/onsecondselapsed.md):
   443    Events triggered by time intervals
   444  * [`onSignalReceived`](../events/onsignalreceived.md):
   445    Trap OS signals
   446  
   447  ## API Reference
   448  
   449  These API docs are provided for any developers wishing to write their own builtins.
   450  
   451  * [`Marshal()` (type)](../apis/Marshal.md):
   452    Converts structured memory into a structured file format (eg for stdio)
   453  * [`ReadArray()` (type)](../apis/ReadArray.md):
   454    Read from a data type one array element at a time
   455  * [`ReadArrayWithType()` (type)](../apis/ReadArrayWithType.md):
   456    Read from a data type one array element at a time and return the elements contents and data type
   457  * [`ReadIndex()` (type)](../apis/ReadIndex.md):
   458    Data type handler for the index, `[`, builtin
   459  * [`ReadMap()` (type)](../apis/ReadMap.md):
   460    Treat data type as a key/value structure and read its contents
   461  * [`ReadNotIndex()` (type)](../apis/ReadNotIndex.md):
   462    Data type handler for the bang-prefixed index, `![`, builtin
   463  * [`Unmarshal()` (type)](../apis/Unmarshal.md):
   464    Converts a structured file format into structured memory
   465  * [`WriteArray()` (type)](../apis/WriteArray.md):
   466    Write a data type, one array element at a time
   467  * [`lang.ArrayTemplate()` (template API)](../apis/lang.ArrayTemplate.md):
   468    Unmarshals a data type into a Go struct and returns the results as an array
   469  * [`lang.ArrayWithTypeTemplate()` (template API)](../apis/lang.ArrayWithTypeTemplate.md):
   470    Unmarshals a data type into a Go struct and returns the results as an array with data type included
   471  * [`lang.IndexTemplateObject()` (template API)](../apis/lang.IndexTemplateObject.md):
   472    Returns element(s) from a data structure
   473  * [`lang.IndexTemplateTable()` (template API)](../apis/lang.IndexTemplateTable.md):
   474    Returns element(s) from a table
   475  * [`lang.MarshalData()` (system API)](../apis/lang.MarshalData.md):
   476    Converts structured memory into a Murex data-type (eg for stdio)
   477  * [`lang.UnmarshalData()` (system API)](../apis/lang.UnmarshalData.md):
   478    Converts a Murex data-type into structured memory