Janet 1.38.0-73334f3 Documentation
(Other Versions: 1.37.1 1.36.0 1.35.0 1.34.0 1.31.0 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


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.


sh/create-dirs function source

(create-dirs dir-path)

Create all directories in path specified as string including itself.


sh/devnull function source

(devnull)

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


sh/escape function source

(escape & args)

Output a string with all arguments correctly quoted


sh/exec function source

(exec & args)

Execute command specified by args returning its exit code


sh/exec-fail function source

(exec-fail & args)

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


sh/exec-slurp function source

(exec-slurp & args)

It executes args with os/spawn and throws an error if the process returns with non-zero exit code. If the process exits with zero exit code, this function trims standard output of the process and returns it. Before the function finishes, the spawned process is closed for resource control.


sh/exec-slurp-all function source

(exec-slurp-all & args)

It executes args with os/spawn and returns a struct which has the following keys.

  • :out - trimmed standard output of the process
  • :err - trimmed standard error of the process
  • :status - the exit code of the process

Before the function finishes, the spawned process is closed for resource control.


sh/exists? function source

(exists? path)

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


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.


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).


sh/rm function source

(rm path)

Remove a directory and all sub directories recursively.


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.


sh/split function source

(split s)

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