|
BashSpark
|
BashSpark - A powerful C++ library for custom command execution.
BashSpark is a command-line tool inspired by the Bash shell that allows users to execute custom commands seamlessly and flexibly. It supports various command types and functionalities tailored for enhanced usability.
BashSpark supports a variety of Bash-style syntaxes including:
${VARIABLE_NAME}${!VARIABLE_NAME}$(command)function function_name {...}Note: Does not recognize semicolons or newlines generated by expansion. Example: $cmd where cmd="echo -n 1; echo -n 2" outputs 1; echo -n 2, not 12.
\n for newline, \t for tab).\x for ASCII\u for UTF-16\U for UTF-32shell_status::SHELL_ERROR_BAD_ENCODING for invalid code points.( and [ are always interpreted, e.g., "echo }" works while "echo \\}" works in both.[[...]].||, && and parentheses (...).(()) is not supported; use the math command instead.variable=value are not supported; use setenv and setvar commands.function_name(){...} is not supported; use fcall function_name <args>.Commands are instantiated from the bs::command class and managed within the shell to ensure safe and reliable command execution by preventing security holes and handling errors gracefully.
The parser has a limit for depth set by std::size_t bs::shell::MAX_DEPTH, defaulting to 16. Users can modify this value and rebuild the project if necessary. The following conditions increase depth:
Parsing variables ${...}, tests [...], and keywords like "then", "fi", "else", "do", "done" do not increase depth.
Current implementation attempts to prevent SIGSEGV. The shell execution does not throw exceptions except for std::bad_alloc or exceptions from provided streams. All errors listed on bs::shell_status are notified through stderr with the last command error code, including syntax errors and depth limit errors.
Other limitations:
std::uint64_t range.