1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

Shell: Add a 'setopt' builtin

This builtin sets (and unsets) boolean flags that alter the behaviour of
the shell.
The only flags added are
- inline_exec_keep_empty_segments: Keep empty segments in the result of
  splitting $(...) by $IFS
- verbose: Announce each command before executing it

It should be noted that the (rather extreme) verbosity of the names is
intentional, and will hopefully be alleviated by the next commit :^)
This commit is contained in:
AnotherTest 2020-06-29 06:22:58 +04:30 committed by Andreas Kling
parent d6de2b5828
commit b8d1edb2a2
5 changed files with 66 additions and 3 deletions

View file

@ -238,15 +238,17 @@ public:
virtual ~StringValue();
virtual bool is_string() const override { return m_split.is_null(); }
virtual bool is_list() const override { return !m_split.is_null(); }
StringValue(String string, String split_by = {})
StringValue(String string, String split_by = {}, bool keep_empty = false)
: m_string(string)
, m_split(move(split_by))
, m_keep_empty(keep_empty)
{
}
private:
String m_string;
String m_split;
bool m_keep_empty { false };
};
class GlobValue final : public Value {