wordexp
The wordexp module implements word expansion using shell semantics, similar to POSIX wordexp(3). Word expansion is performed with the platform-specific system shell, which is generally POSIX sh(1) compatible on Unix-like systems.
When used with a POSIX shell, the IFS variable is unconditionally unset in the environment, causing the shell to assume the default value of " \t\n".
Note that, by design, this module runs arbitrary shell commands from user-supplied inputs. It must only be used in a trusted environment.
Index
Types
type flag = enum uint {
NONE = 0,
SHOWERR = 1 << 4,
UNDEF = 1 << 5,
};
Errors
type error = !(io::error | exec::error | utf8::invalid | sh_error);
type sh_error = !void;
Functions
fn strerror(err: error) const str;
fn wordexp(s: str, flags: flag = flag::NONE) ([]str | error);
Types
type flag
type flag = enum uint {
NONE = 0,
SHOWERR = 1 << 4,
UNDEF = 1 << 5,
};
Flags applicable to a wordexp operation.
Errors
type error
type error = !(io::error | exec::error | utf8::invalid | sh_error);
Tagged union of possible wordexp error conditions.
type sh_error
type sh_error = !void;
An error occured during shell expansion.
Functions
fn strerror
fn strerror(err: error) const str;
Converts an error to a human-friendly string.
fn wordexp
fn wordexp(s: str, flags: flag = flag::NONE) ([]str | error);
Performs shell expansion and word splitting on the provided string, returning a list of expanded words, similar to POSIX wordexp(3). Note that this function, by design, will execute arbitrary commands from the input string.
Pass the return value to strings::freeall to free resources associated with the return value.