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

     1  # `paths`
     2  
     3  > Structured array for working with `$PATH` style data
     4  
     5  ## Description
     6  
     7  The `path` type Turns file and directory paths into structured objects.
     8  
     9  The root directory (typically `/`) is counted as a directory. If a path is
    10  relative rather than absolute then `/` will be excluded from outputted string.
    11  
    12  ## Examples
    13  
    14  **Creating a PATH:**
    15  
    16  ```
    17  » %[/bin, /usr/bin, "$JAVA_HOME/bin"] -> format paths
    18  /bin:/usr/bin:/opt/java/bin
    19  ```
    20  
    21  **Splitting a PATH:**
    22  
    23  ```
    24  » $PATH -> :paths: format json
    25  [
    26      "/bin",
    27      "/usr/bin",
    28      "/opt/java/bin"
    29  ]
    30  ```
    31  
    32  **Appending to `$PATH`:**
    33  
    34  ```
    35  » $PATH -> :paths: append /sbin -> export PATH
    36  » $PATH
    37  /bin:/usr/bin:/opt/java/bin:/sbin
    38  ```
    39  
    40  ## Supported Hooks
    41  
    42  * `Marshal()`
    43      Supported
    44  * `ReadArray()`
    45      Each element is a directory branch. Root, `/`, is treated as it's own element
    46  * `ReadArrayWithType()`
    47      Same as `ReadArray()`
    48  * `ReadIndex()`
    49      Returns a directory branch or filename if last element is a file
    50  * `ReadMap()`
    51      Not currently supported
    52  * `ReadNotIndex()`
    53      Supported
    54  * `Unmarshal()`
    55      Supported
    56  * `WriteArray()`
    57      Each element is a directory branch
    58  
    59  ## See Also
    60  
    61  * [MUREX_EXE](../variables/murex_exe.md):
    62    Absolute path to running shell
    63  * [PWD](../variables/pwd.md):
    64    Current working directory
    65  * [PWDHIST](../variables/pwdhist.md):
    66    History of each change to the sessions working directory
    67  * [`path`](../types/path.md):
    68    Structured object for working with file and directory paths
    69  
    70  ### Read more about type hooks
    71  
    72  - [`ReadIndex()` (type)](../apis/ReadIndex.md): Data type handler for the index, `[`, builtin
    73  - [`ReadNotIndex()` (type)](../apis/ReadNotIndex.md): Data type handler for the bang-prefixed index, `![`, builtin
    74  - [`ReadArray()` (type)](../apis/ReadArray.md): Read from a data type one array element at a time
    75  - [`WriteArray()` (type)](../apis/WriteArray.md): Write a data type, one array element at a time
    76  - [`ReadMap()` (type)](../apis/ReadMap.md): Treat data type as a key/value structure and read its contents
    77  - [`Marshal()` (type)](../apis/Marshal.md): Converts structured memory into a structured file format (eg for stdio)
    78  - [`Unmarshal()` (type)](../apis/Unmarshal.md): Converts a structured file format into structured memory
    79  
    80  <hr/>
    81  
    82  This document was generated from [builtins/types/paths/paths_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/types/paths/paths_doc.yaml).