path: Filesystem path utilities

Table of content

Introduction

The path: module provides functions for manipulating and testing filesystem paths.

Function usages are given in the same format as in the reference doc for the builtin module.

Variables

$path:dev-null

Compatibility alias for $os:dev-null. This variable will be formally deprecated and removed in future.

$path:dev-tty

Compatibility alias for $os:dev-tty. This variable will be formally deprecated and removed in future.

$path:list-separator

OS-specific path list separator. Colon (:) on Unix and semicolon (;) on Windows. This variable is read-only.

$path:separator

OS-specific path separator. Forward slash (/) on Unix and backslash (\) on Windows. This variable is read-only.

Functions

path:abs

path:abs $path

Outputs $path converted to an absolute path.

~> cd ~
~> path:abs bin
▶ /home/user/bin

path:base

path:base $path

Outputs the last element of $path. This is analogous to the POSIX basename command. See the Go documentation for more details.

~> path:base ~/bin
▶ bin

path:clean

path:clean $path

Outputs the shortest version of $path equivalent to $path by purely lexical processing. This is most useful for eliminating unnecessary relative path elements such as . and .. without asking the OS to evaluate the path name. See the Go documentation for more details.

~> path:clean ./../bin
▶ ../bin

path:dir

path:dir $path

Outputs all but the last element of $path, typically the path’s enclosing directory. See the Go documentation for more details. This is analogous to the POSIX dirname command.

~> path:dir /a/b/c/something
▶ /a/b/c

path:eval-symlinks $path

Compatibility alias for os:eval-symlinks. This function will be formally deprecated and removed in future.

path:ext

path:ext $path

Outputs the file name extension used by $path (including the separating period). If there is no extension the empty string is output. See the Go documentation for more details.

~> path:ext hello.elv
▶ .elv

path:is-abs

path:is-abs $path

Outputs $true if the path is an absolute path. Note that platforms like Windows have different rules than Unix like platforms for what constitutes an absolute path. See the Go documentation for more details.

~> path:is-abs hello.elv
▶ false
~> path:is-abs /hello.elv
▶ true

path:is-dir

path:is-dir &follow-symlink=$false $path

Compatibility alias for os:is-dir. This function will be formally deprecated and removed in future.

path:is-regular

path:is-regular &follow-symlink=$false $path

Compatibility alias for os:is-regular. This function will be formally deprecated and removed in future.

path:join

path:join $path-component...

Joins any number of path elements into a single path, separating them with an OS specific separator. Empty elements are ignored. The result is cleaned. However, if the argument list is empty or all its elements are empty, Join returns an empty string. On Windows, the result will only be a UNC path if the first non-empty element is a UNC path.

~> path:join home user bin
▶ home/user/bin
~> path:join $path:separator home user bin
▶ /home/user/bin

path:temp-dir

path:temp-dir &dir='' $pattern?

Compatibility alias for os:temp-dir. This function will be formally deprecated and removed in future.

path:temp-file

path:temp-file &dir='' $pattern?

Compatibility alias for os:temp-file. This function will be formally deprecated and removed in future.