pandoc.system

arch

string

The machine architecture on which the program is running.

environment

function pandoc.system.environment()
  -> table<string, string>

Retrieve the entire environment as a string-indexed table.

Returns:

  • A table mapping environment variables names to their string value

get_working_directory

function pandoc.system.get_working_directory()
  -> string

Obtain the current working directory as an absolute path.

Returns:

  • The current working directory

list_directory

function pandoc.system.list_directory(directory?: string)
  -> table

List the contents of a directory.

make_directory

function pandoc.system.make_directory(dirname: string, create_parent?: boolean)

Create a new directory which is initially empty, or as near to empty as the operating system allows. The function throws an error if the directory cannot be created, e.g., if the parent directory does not exist or if a directory of the same name is already present.

If the optional second parameter is provided and truthy, then all directories, including parent directories, are created as necessary.

os

string

The operating system on which the program is running.

remove_directory

function pandoc.system.remove_directory(dirname: string, recursive?: boolean)

Remove an existing, empty directory. If recursive is given, then delete the directory and its contents recursively.

with_environment

function pandoc.system.with_environment(environment: table<string, string>, callback: fun():unknown)
  -> unknown
  • Run an action within a custom environment. Only the environment – variables given by environment will be set, when callback is – called. The original environment is restored after this function – finishes, even if an error occurs while running the callback – action.

with_temporary_directory

function pandoc.system.with_temporary_directory(templ: string, callback: fun(x: string):unknown)
  -> unknown

Create and use a temporary directory inside the the system’s canonical temporary directory. The directory is deleted after the callback returns.

with_working_directory

function pandoc.system.with_working_directory(directory: string, callback: fun():unknown)
  -> unknown

Run an action within a different directory. This function will change the working directory to directory, execute callback, then switch back to the original working directory, even if an error occurs while running the callback action.