src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/mods/path/path.d.elv (about)

     1  # Compatibility alias for [`$os:dev-null`](). This variable will be formally
     2  # deprecated and removed in future.
     3  var dev-null
     4  
     5  # Compatibility alias for [`$os:dev-tty`](). This variable will be formally
     6  # deprecated and removed in future.
     7  var dev-tty
     8  
     9  # OS-specific path list separator. Colon (`:`) on Unix and semicolon (`;`) on
    10  # Windows. This variable is read-only.
    11  var list-separator
    12  
    13  # OS-specific path separator. Forward slash (`/`) on Unix and backslash (`\`)
    14  # on Windows. This variable is read-only.
    15  var separator
    16  
    17  # Outputs `$path` converted to an absolute path.
    18  #
    19  # ```elvish-transcript
    20  # ~> cd ~
    21  # ~> path:abs bin
    22  # ▶ /home/user/bin
    23  # ```
    24  fn abs {|path| }
    25  
    26  # Outputs the last element of `$path`. This is analogous to the POSIX `basename` command. See the
    27  # [Go documentation](https://pkg.go.dev/path/filepath#Base) for more details.
    28  #
    29  # ```elvish-transcript
    30  # ~> path:base ~/bin
    31  # ▶ bin
    32  # ```
    33  fn base {|path| }
    34  
    35  # Outputs the shortest version of `$path` equivalent to `$path` by purely lexical processing. This
    36  # is most useful for eliminating unnecessary relative path elements such as `.` and `..` without
    37  # asking the OS to evaluate the path name. See the [Go
    38  # documentation](https://pkg.go.dev/path/filepath#Clean) for more details.
    39  #
    40  # ```elvish-transcript
    41  # ~> path:clean ./../bin
    42  # ▶ ../bin
    43  # ```
    44  fn clean {|path| }
    45  
    46  # Outputs all but the last element of `$path`, typically the path's enclosing directory. See the
    47  # [Go documentation](https://pkg.go.dev/path/filepath#Dir) for more details. This is analogous to
    48  # the POSIX `dirname` command.
    49  #
    50  # ```elvish-transcript
    51  # ~> path:dir /a/b/c/something
    52  # ▶ /a/b/c
    53  # ```
    54  fn dir {|path| }
    55  
    56  # Outputs the file name extension used by `$path` (including the separating period). If there is no
    57  # extension the empty string is output. See the [Go
    58  # documentation](https://pkg.go.dev/path/filepath#Ext) for more details.
    59  #
    60  # ```elvish-transcript
    61  # ~> path:ext hello.elv
    62  # ▶ .elv
    63  # ```
    64  fn ext {|path| }
    65  
    66  # Outputs `$true` if the path is an absolute path. Note that platforms like Windows have different
    67  # rules than Unix like platforms for what constitutes an absolute path. See the [Go
    68  # documentation](https://pkg.go.dev/path/filepath#IsAbs) for more details.
    69  #
    70  # ```elvish-transcript
    71  # ~> path:is-abs hello.elv
    72  # ▶ false
    73  # ~> path:is-abs /hello.elv
    74  # ▶ true
    75  # ```
    76  fn is-abs {|path| }
    77  
    78  # Compatibility alias for [`os:eval-symlinks`](). This function will be formally
    79  # deprecated and removed in future.
    80  fn eval-symlinks {|path| }
    81  
    82  # Joins any number of path elements into a single path, separating them with an
    83  # [OS specific separator](#$path:separator). Empty elements are ignored. The
    84  # result is [cleaned](#path:clean). However, if the argument list is empty or
    85  # all its elements are empty, Join returns an empty string. On Windows, the
    86  # result will only be a UNC path if the first non-empty element is a UNC path.
    87  #
    88  # ```elvish-transcript
    89  # ~> path:join home user bin
    90  # ▶ home/user/bin
    91  # ~> path:join $path:separator home user bin
    92  # ▶ /home/user/bin
    93  # ```
    94  fn join {|@path-component| }
    95  
    96  # Compatibility alias for [`os:is-dir`](). This function will be formally
    97  # deprecated and removed in future.
    98  fn is-dir {|&follow-symlink=$false path| }
    99  
   100  # Compatibility alias for [`os:is-regular`](). This function will be formally
   101  # deprecated and removed in future.
   102  fn is-regular {|&follow-symlink=$false path| }
   103  
   104  # Compatibility alias for [`os:temp-dir`](). This function will be formally
   105  # deprecated and removed in future.
   106  fn temp-dir {|&dir='' pattern?| }
   107  
   108  # Compatibility alias for [`os:temp-file`](). This function will be formally
   109  # deprecated and removed in future.
   110  fn temp-file {|&dir='' pattern?| }