1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:08:12 +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

@ -818,7 +818,7 @@ RefPtr<Value> Execute::run(RefPtr<Shell> shell)
dbg() << "close() failed: " << strerror(errno);
}
return create<StringValue>(builder.build(), shell->local_variable_or("IFS", "\n"));
return create<StringValue>(builder.build(), shell->local_variable_or("IFS", "\n"), shell->options.inline_exec_keep_empty_segments);
}
run_commands(commands);
@ -1799,7 +1799,7 @@ StringValue::~StringValue()
Vector<String> StringValue::resolve_as_list(RefPtr<Shell>)
{
if (is_list()) {
auto parts = StringView(m_string).split_view(m_split);
auto parts = StringView(m_string).split_view(m_split, m_keep_empty);
Vector<String> result;
result.ensure_capacity(parts.size());
for (auto& part : parts)