Parse strings like, and escape strings for, POSIX shells.
Same idea as (but implementation not directly based on) the Python shlex module.
std feature (which is enabled by default) will allow the crate to work in
no_std environments, where the
alloc crate, and a global allocator, are available.
This is fully safe in noninteractive contexts, like shell scripts and
sh -c arguments (or
sourced from interactive shells).
But if you are quoting for human consumption, you should keep in mind that ugly inputs produce ugly outputs (which may not be copy-pastable).
For more information, and for information about more minor issues, please see quoting_warning.
This crate’s quoting functionality tries to be compatible with any POSIX-compatible shell;
it’s tested against
fish (which is not
POSIX-compatible but close enough).
It also aims to be compatible with Python
shlex and C
Shlexand friends for byte strings.
- A more detailed version of the warning at the top level about the
joinfamily of APIs.
- An iterator that takes an input string and splits it into the words using the same syntax as the POSIX shell.
- joinDeprecatedConvenience function that consumes an iterable of words and turns it into a single string, quoting words when necessary. Consecutive words will be separated by a single space.
- quoteDeprecatedGiven a single word, return a string suitable to encode it as a shell argument.
- Convenience function that consumes the whole string at once. Returns None if the input was erroneous.
- Convenience function that consumes an iterable of words and turns it into a single string, quoting words when necessary. Consecutive words will be separated by a single space.
- Given a single word, return a string suitable to encode it as a shell argument.