Janet 1.31.0-4e5889e Documentation
(Other Versions: 1.29.1 1.28.0 1.27.0 1.26.0 1.25.1 1.24.0 1.23.0 1.22.0 1.21.0 1.20.0 1.19.0 1.18.1 1.17.1 1.16.1 1.15.0 1.13.1 1.12.2 1.11.1 1.10.1 1.9.1 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )

Shell Utilities

Index

sh/copy sh/copy-file sh/create-dirs sh/devnull sh/escape sh/exec sh/exec-fail sh/exec-slurp sh/exec-slurp-all sh/exists? sh/list-all-files sh/make-new-file sh/rm sh/scan-directory sh/split


sh/copy function source
(copy src dest)

Copy a file or directory recursively from one location to another.
Expects input to be unix style paths
Community Examples

sh/copy-file function source
(copy-file src-path dst-path)

Copy a file from source to destination. Creates all directories in the path to the destination file if they do not exist.
Community Examples

sh/create-dirs function source
(create-dirs dir-path)

Create all directories in path specified as string including itself.
Community Examples

sh/devnull function source
(devnull)

get the /dev/null equivalent of the current platform as an open file
Community Examples

sh/escape function source
(escape & args)

Output a string with all arguments correctly quoted
Community Examples

sh/exec function source
(exec & args)

Execute command specified by args returning it's exit code
Community Examples

sh/exec-fail function source
(exec-fail & args)

Execute command specified by args, fails when command exits with non-zero exit code
Community Examples

sh/exec-slurp function source
(exec-slurp & args)

Read stdout of command specified by args and return it trimmed in a string.
Community Examples

sh/exec-slurp-all function source
(exec-slurp-all & args)

Read stdout and stderr of subprocess and return it trimmed in a struct with :err and :out containing the output as string.
This will also return the exit code under the :status key.
Community Examples

sh/exists? function source
(exists? path)

Check if the given file or directory exists. (Follows symlinks)
Community Examples

sh/list-all-files function source
(list-all-files dir &opt into)

List the files in the given directory recursively. Return the paths to all files found, relative to the current working directory if the given path is a relative path, or as an absolute path otherwise.
Community Examples

sh/make-new-file function source
(make-new-file file-path &opt mode)

Create and open a file, creating all the directories leading to the file if they do not exist, and return it. By default, open as a writable file (mode is `:w`).
Community Examples

sh/rm function source
(rm path)

Remove a directory and all sub directories recursively.
Community Examples

sh/scan-directory function source
(scan-directory dir func)

Scan a directory recursively, applying the given function on all files and directories in a depth-first manner. This function has no effect if the directory does not exist.
Community Examples

sh/split function source
(split s)

Split a string into 'sh like' tokens, returns nil if unable to parse the string.
Community Examples