diff options
author | Linus Groh <mail@linusgroh.de> | 2022-12-04 18:02:33 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-06 08:54:33 +0100 |
commit | 6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch) | |
tree | 372d21b2f5dcff112f5d0089559c6af5798680d4 /Userland/Shell | |
parent | f74251606d74b504a1379ebb893fdb5529054ea5 (diff) | |
download | serenity-6e19ab2bbce0b113b628e6f8e9b5c0640053933e.zip |
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
Diffstat (limited to 'Userland/Shell')
-rw-r--r-- | Userland/Shell/AST.cpp | 160 | ||||
-rw-r--r-- | Userland/Shell/AST.h | 144 | ||||
-rw-r--r-- | Userland/Shell/Builtin.cpp | 40 | ||||
-rw-r--r-- | Userland/Shell/Execution.h | 2 | ||||
-rw-r--r-- | Userland/Shell/Formatter.cpp | 6 | ||||
-rw-r--r-- | Userland/Shell/Formatter.h | 8 | ||||
-rw-r--r-- | Userland/Shell/ImmediateFunctions.cpp | 18 | ||||
-rw-r--r-- | Userland/Shell/Job.cpp | 2 | ||||
-rw-r--r-- | Userland/Shell/Job.h | 10 | ||||
-rw-r--r-- | Userland/Shell/Parser.cpp | 34 | ||||
-rw-r--r-- | Userland/Shell/Parser.h | 4 | ||||
-rw-r--r-- | Userland/Shell/Shell.cpp | 104 | ||||
-rw-r--r-- | Userland/Shell/Shell.h | 86 | ||||
-rw-r--r-- | Userland/Shell/main.cpp | 6 |
14 files changed, 312 insertions, 312 deletions
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 2de5497496..66258f4a60 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -6,10 +6,10 @@ #include "AST.h" #include "Shell.h" +#include <AK/DeprecatedString.h> #include <AK/MemoryStream.h> #include <AK/ScopeGuard.h> #include <AK/ScopedValueRollback.h> -#include <AK/String.h> #include <AK/StringBuilder.h> #include <AK/URL.h> #include <LibCore/EventLoop.h> @@ -108,7 +108,7 @@ namespace Shell::AST { static inline void print_indented(StringView str, int indent) { - dbgln("{}{}", String::repeated(' ', indent * 2), str); + dbgln("{}{}", DeprecatedString::repeated(' ', indent * 2), str); } static inline Optional<Position> merge_positions(Optional<Position> const& left, Optional<Position> const& right) @@ -154,7 +154,7 @@ static inline Vector<Command> join_commands(Vector<Command> left, Vector<Command return commands; } -static String resolve_slices(RefPtr<Shell> shell, String&& input_value, NonnullRefPtrVector<Slice> slices) +static DeprecatedString resolve_slices(RefPtr<Shell> shell, DeprecatedString&& input_value, NonnullRefPtrVector<Slice> slices) { if (slices.is_empty()) return move(input_value); @@ -177,7 +177,7 @@ static String resolve_slices(RefPtr<Shell> shell, String&& input_value, NonnullR for (auto& value : index_values) { auto maybe_index = value.to_int(); if (!maybe_index.has_value()) { - shell->raise_error(Shell::ShellError::InvalidSliceContentsError, String::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position()); + shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position()); return move(input_value); } ++i; @@ -188,7 +188,7 @@ static String resolve_slices(RefPtr<Shell> shell, String&& input_value, NonnullR index += input_value.length(); if (index < 0 || (size_t)index >= input_value.length()) { - shell->raise_error(Shell::ShellError::InvalidSliceContentsError, String::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.length()), slice.position()); + shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.length()), slice.position()); return move(input_value); } indices.unchecked_append(index); @@ -204,7 +204,7 @@ static String resolve_slices(RefPtr<Shell> shell, String&& input_value, NonnullR return move(input_value); } -static Vector<String> resolve_slices(RefPtr<Shell> shell, Vector<String>&& values, NonnullRefPtrVector<Slice> slices) +static Vector<DeprecatedString> resolve_slices(RefPtr<Shell> shell, Vector<DeprecatedString>&& values, NonnullRefPtrVector<Slice> slices) { if (slices.is_empty()) return move(values); @@ -227,7 +227,7 @@ static Vector<String> resolve_slices(RefPtr<Shell> shell, Vector<String>&& value for (auto& value : index_values) { auto maybe_index = value.to_int(); if (!maybe_index.has_value()) { - shell->raise_error(Shell::ShellError::InvalidSliceContentsError, String::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position()); + shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position()); return move(values); } ++i; @@ -238,13 +238,13 @@ static Vector<String> resolve_slices(RefPtr<Shell> shell, Vector<String>&& value index += values.size(); if (index < 0 || (size_t)index >= values.size()) { - shell->raise_error(Shell::ShellError::InvalidSliceContentsError, String::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice.position()); + shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice.position()); return move(values); } indices.unchecked_append(index); } - Vector<String> result; + Vector<DeprecatedString> result; result.ensure_capacity(indices.size()); for (auto& index : indices) result.unchecked_append(values[index]); @@ -315,7 +315,7 @@ Vector<Command> Node::to_lazy_evaluated_commands(RefPtr<Shell> shell) void Node::dump(int level) const { - print_indented(String::formatted("{} at {}:{} (from {}.{} to {}.{})", + print_indented(DeprecatedString::formatted("{} at {}:{} (from {}.{} to {}.{})", class_name().characters(), m_position.start_offset, m_position.end_offset, @@ -380,7 +380,7 @@ Vector<Line::CompletionSuggestion> Node::complete_for_editor(Shell& shell, size_ if (!program_name_node) return {}; - String program_name; + DeprecatedString program_name; if (program_name_node->is_bareword()) program_name = static_cast<BarewordLiteral*>(program_name_node.ptr())->text(); else @@ -666,7 +666,7 @@ void BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi } } -BarewordLiteral::BarewordLiteral(Position position, String text) +BarewordLiteral::BarewordLiteral(Position position, DeprecatedString text) : Node(move(position)) , m_text(move(text)) { @@ -857,7 +857,7 @@ CastToList::CastToList(Position position, RefPtr<Node> inner) void CloseFdRedirection::dump(int level) const { Node::dump(level); - print_indented(String::formatted("{} -> Close", m_fd), level); + print_indented(DeprecatedString::formatted("{} -> Close", m_fd), level); } RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>) @@ -887,7 +887,7 @@ CloseFdRedirection::~CloseFdRedirection() void CommandLiteral::dump(int level) const { Node::dump(level); - print_indented(String::formatted("(Generated command literal: {})", m_command), level + 1); + print_indented(DeprecatedString::formatted("(Generated command literal: {})", m_command), level + 1); } RefPtr<Value> CommandLiteral::run(RefPtr<Shell>) @@ -921,7 +921,7 @@ void Comment::highlight_in_editor(Line::Editor& editor, Shell&, HighlightMetadat editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(150, 150, 150) }); // Light gray } -Comment::Comment(Position position, String text) +Comment::Comment(Position position, DeprecatedString text) : Node(move(position)) , m_text(move(text)) { @@ -1048,7 +1048,7 @@ DynamicEvaluate::~DynamicEvaluate() void Fd2FdRedirection::dump(int level) const { Node::dump(level); - print_indented(String::formatted("{} -> {}", m_old_fd, m_new_fd), level); + print_indented(DeprecatedString::formatted("{} -> {}", m_old_fd, m_new_fd), level); } RefPtr<Value> Fd2FdRedirection::run(RefPtr<Shell>) @@ -1078,10 +1078,10 @@ Fd2FdRedirection::~Fd2FdRedirection() void FunctionDeclaration::dump(int level) const { Node::dump(level); - print_indented(String::formatted("(name: {})\n", m_name.name), level + 1); + print_indented(DeprecatedString::formatted("(name: {})\n", m_name.name), level + 1); print_indented("(argument names)"sv, level + 1); for (auto& arg : m_arguments) - print_indented(String::formatted("(name: {})\n", arg.name), level + 2); + print_indented(DeprecatedString::formatted("(name: {})\n", arg.name), level + 2); print_indented("(body)"sv, level + 1); if (m_block) @@ -1092,7 +1092,7 @@ void FunctionDeclaration::dump(int level) const RefPtr<Value> FunctionDeclaration::run(RefPtr<Shell> shell) { - Vector<String> args; + Vector<DeprecatedString> args; for (auto& arg : m_arguments) args.append(arg.name); @@ -1167,9 +1167,9 @@ void ForLoop::dump(int level) const { Node::dump(level); if (m_variable.has_value()) - print_indented(String::formatted("iterating with {} in", m_variable->name), level + 1); + print_indented(DeprecatedString::formatted("iterating with {} in", m_variable->name), level + 1); if (m_index_variable.has_value()) - print_indented(String::formatted("with index name {} in", m_index_variable->name), level + 1); + print_indented(DeprecatedString::formatted("with index name {} in", m_index_variable->name), level + 1); if (m_iterated_expression) m_iterated_expression->dump(level + 2); else @@ -1237,11 +1237,11 @@ RefPtr<Value> ForLoop::run(RefPtr<Shell> shell) RefPtr<Value> block_value; { - auto frame = shell->push_frame(String::formatted("for ({})", this)); + auto frame = shell->push_frame(DeprecatedString::formatted("for ({})", this)); shell->set_local_variable(variable_name, value, true); if (index_name.has_value()) - shell->set_local_variable(index_name.value(), make_ref_counted<AST::StringValue>(String::number(i)), true); + shell->set_local_variable(index_name.value(), make_ref_counted<AST::StringValue>(DeprecatedString::number(i)), true); ++i; @@ -1349,7 +1349,7 @@ void Glob::highlight_in_editor(Line::Editor& editor, Shell&, HighlightMetadata m editor.stylize({ m_position.start_offset, m_position.end_offset }, move(style)); } -Glob::Glob(Position position, String text) +Glob::Glob(Position position, DeprecatedString text) : Node(move(position)) , m_text(move(text)) { @@ -1365,7 +1365,7 @@ void Heredoc::dump(int level) const print_indented("(End Key)"sv, level + 1); print_indented(m_end, level + 2); print_indented("(Allows Interpolation)"sv, level + 1); - print_indented(String::formatted("{}", m_allows_interpolation), level + 2); + print_indented(DeprecatedString::formatted("{}", m_allows_interpolation), level + 2); print_indented("(Contents)"sv, level + 1); if (m_contents) m_contents->dump(level + 2); @@ -1422,7 +1422,7 @@ HitTestResult Heredoc::hit_test_position(size_t offset) const return m_contents->hit_test_position(offset); } -Heredoc::Heredoc(Position position, String end, bool allow_interpolation, bool deindent) +Heredoc::Heredoc(Position position, DeprecatedString end, bool allow_interpolation, bool deindent) : Node(move(position)) , m_end(move(end)) , m_allows_interpolation(allow_interpolation) @@ -1452,16 +1452,16 @@ void HistoryEvent::dump(int level) const print_indented("StartingStringLookup"sv, level + 2); break; } - print_indented(String::formatted("{}({})", m_selector.event.index, m_selector.event.text), level + 3); + print_indented(DeprecatedString::formatted("{}({})", m_selector.event.index, m_selector.event.text), level + 3); print_indented("Word Selector"sv, level + 1); auto print_word_selector = [&](HistorySelector::WordSelector const& selector) { switch (selector.kind) { case HistorySelector::WordSelectorKind::Index: - print_indented(String::formatted("Index {}", selector.selector), level + 3); + print_indented(DeprecatedString::formatted("Index {}", selector.selector), level + 3); break; case HistorySelector::WordSelectorKind::Last: - print_indented(String::formatted("Last"), level + 3); + print_indented(DeprecatedString::formatted("Last"), level + 3); break; } }; @@ -1500,7 +1500,7 @@ RefPtr<Value> HistoryEvent::run(RefPtr<Shell> shell) return it_end; }; // First, resolve the event itself. - String resolved_history; + DeprecatedString resolved_history; switch (m_selector.event.kind) { case HistorySelector::EventKind::IndexFromStart: if (m_selector.event.index >= history.size()) { @@ -1764,7 +1764,7 @@ void Execute::for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(Non auto entry = entry_result.release_value(); auto rc = stream.read_or_error(entry); VERIFY(rc); - callback(make_ref_counted<StringValue>(String::copy(entry))); + callback(make_ref_counted<StringValue>(DeprecatedString::copy(entry))); } } @@ -2112,9 +2112,9 @@ Join::~Join() void MatchExpr::dump(int level) const { Node::dump(level); - print_indented(String::formatted("(expression: {})", m_expr_name.characters()), level + 1); + print_indented(DeprecatedString::formatted("(expression: {})", m_expr_name.characters()), level + 1); m_matched_expr->dump(level + 2); - print_indented(String::formatted("(named: {})", m_expr_name.characters()), level + 1); + print_indented(DeprecatedString::formatted("(named: {})", m_expr_name.characters()), level + 1); print_indented("(entries)"sv, level + 1); for (auto& entry : m_entries) { StringBuilder builder; @@ -2141,7 +2141,7 @@ void MatchExpr::dump(int level) const }, [&](Vector<Regex<ECMA262>> const& options) { for (auto& option : options) - print_indented(String::formatted("(regex: {})", option.pattern_value), level + 3); + print_indented(DeprecatedString::formatted("(regex: {})", option.pattern_value), level + 3); }); print_indented("(execute)"sv, level + 2); if (entry.body) @@ -2194,7 +2194,7 @@ RefPtr<Value> MatchExpr::run(RefPtr<Shell> shell) if constexpr (IsSame<RemoveCVReference<decltype(option)>, Regex<ECMA262>>) { return option; } else { - Vector<String> pattern; + Vector<DeprecatedString> pattern; if (option.is_glob()) { pattern.append(static_cast<const Glob*>(&option)->text()); } else if (option.is_bareword()) { @@ -2215,14 +2215,14 @@ RefPtr<Value> MatchExpr::run(RefPtr<Shell> shell) } }; - auto frame = shell->push_frame(String::formatted("match ({})", this)); + auto frame = shell->push_frame(DeprecatedString::formatted("match ({})", this)); if (!m_expr_name.is_empty()) shell->set_local_variable(m_expr_name, value, true); for (auto& entry : m_entries) { auto result = entry.options.visit([&](auto& options) -> Variant<IterationDecision, RefPtr<Value>> { for (auto& option : options) { - Vector<String> spans; + Vector<DeprecatedString> spans; if (list_matches(resolve_pattern(option), spans)) { if (entry.body) { if (entry.match_names.has_value()) { @@ -2298,7 +2298,7 @@ HitTestResult MatchExpr::hit_test_position(size_t offset) const return {}; } -MatchExpr::MatchExpr(Position position, NonnullRefPtr<Node> expr, String name, Optional<Position> as_position, Vector<MatchEntry> entries) +MatchExpr::MatchExpr(Position position, NonnullRefPtr<Node> expr, DeprecatedString name, Optional<Position> as_position, Vector<MatchEntry> entries) : Node(move(position)) , m_matched_expr(move(expr)) , m_expr_name(move(name)) @@ -2495,7 +2495,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell auto& position = m_path->position(); auto& path = path_text[0]; if (!path.starts_with('/')) - path = String::formatted("{}/{}", shell.cwd, path); + path = DeprecatedString::formatted("{}/{}", shell.cwd, path); auto url = URL::create_with_file_scheme(path); url.set_host(shell.hostname); editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_string()) }); @@ -2573,16 +2573,16 @@ RefPtr<Value> Range::run(RefPtr<Shell> shell) auto end = end_int.value(); auto step = start > end ? -1 : 1; for (int value = start; value != end; value += step) - values.append(make_ref_counted<StringValue>(String::number(value))); + values.append(make_ref_counted<StringValue>(DeprecatedString::number(value))); // Append the range end too, most shells treat this as inclusive. - values.append(make_ref_counted<StringValue>(String::number(end))); + values.append(make_ref_counted<StringValue>(DeprecatedString::number(end))); } else { goto yield_start_end; } } } else { yield_start_end:; - shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, String::formatted("Cannot interpolate between '{}' and '{}'!", start_str, end_str), position); + shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Cannot interpolate between '{}' and '{}'!", start_str, end_str), position); // We can't really interpolate between the two, so just yield both. values.append(make_ref_counted<StringValue>(move(start_str))); values.append(make_ref_counted<StringValue>(move(end_str))); @@ -2654,7 +2654,7 @@ void ReadRedirection::dump(int level) const { Node::dump(level); m_path->dump(level + 1); - print_indented(String::formatted("To {}", m_fd), level + 1); + print_indented(DeprecatedString::formatted("To {}", m_fd), level + 1); } RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell) @@ -2684,7 +2684,7 @@ void ReadWriteRedirection::dump(int level) const { Node::dump(level); m_path->dump(level + 1); - print_indented(String::formatted("To/From {}", m_fd), level + 1); + print_indented(DeprecatedString::formatted("To/From {}", m_fd), level + 1); } RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell) @@ -2927,7 +2927,7 @@ Vector<Line::CompletionSuggestion> SimpleVariable::complete_for_editor(Shell& sh return shell.complete_variable(m_name, corrected_offset); } -SimpleVariable::SimpleVariable(Position position, String name) +SimpleVariable::SimpleVariable(Position position, DeprecatedString name) : VariableNode(move(position)) , m_name(move(name)) { @@ -2941,7 +2941,7 @@ void SpecialVariable::dump(int level) const { Node::dump(level); print_indented("(Name)"sv, level + 1); - print_indented(String { &m_name, 1 }, level + 1); + print_indented(DeprecatedString { &m_name, 1 }, level + 1); print_indented("(Slice)"sv, level + 1); if (m_slice) m_slice->dump(level + 2); @@ -3023,7 +3023,7 @@ RefPtr<Value> Juxtaposition::run(RefPtr<Shell> shell) if (left.is_empty() || right.is_empty()) return make_ref_counted<ListValue>({}); - Vector<String> result; + Vector<DeprecatedString> result; result.ensure_capacity(left.size() * right.size()); StringBuilder builder; @@ -3154,7 +3154,7 @@ void StringLiteral::highlight_in_editor(Line::Editor& editor, Shell&, HighlightM editor.stylize({ m_position.start_offset, m_position.end_offset }, move(style)); } -StringLiteral::StringLiteral(Position position, String text, EnclosureType enclosure_type) +StringLiteral::StringLiteral(Position position, DeprecatedString text, EnclosureType enclosure_type) : Node(move(position)) , m_text(move(text)) , m_enclosure_type(enclosure_type) @@ -3224,7 +3224,7 @@ void SyntaxError::dump(int level) const print_indented("(Error text)"sv, level + 1); print_indented(m_syntax_error_text, level + 2); print_indented("(Can be recovered from)"sv, level + 1); - print_indented(String::formatted("{}", m_is_continuable), level + 2); + print_indented(DeprecatedString::formatted("{}", m_is_continuable), level + 2); } RefPtr<Value> SyntaxError::run(RefPtr<Shell> shell) @@ -3238,7 +3238,7 @@ void SyntaxError::highlight_in_editor(Line::Editor& editor, Shell&, HighlightMet editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Red), Line::Style::Bold }); } -SyntaxError::SyntaxError(Position position, String error, bool is_continuable) +SyntaxError::SyntaxError(Position position, DeprecatedString error, bool is_continuable) : Node(move(position)) , m_syntax_error_text(move(error)) , m_is_continuable(is_continuable) @@ -3314,7 +3314,7 @@ Vector<Line::CompletionSuggestion> Tilde::complete_for_editor(Shell& shell, size return shell.complete_user(m_username, corrected_offset); } -String Tilde::text() const +DeprecatedString Tilde::text() const { StringBuilder builder; builder.append('~'); @@ -3322,7 +3322,7 @@ String Tilde::text() const return builder.to_string(); } -Tilde::Tilde(Position position, String username) +Tilde::Tilde(Position position, DeprecatedString username) : Node(move(position)) , m_username(move(username)) { @@ -3336,7 +3336,7 @@ void WriteAppendRedirection::dump(int level) const { Node::dump(level); m_path->dump(level + 1); - print_indented(String::formatted("From {}", m_fd), level + 1); + print_indented(DeprecatedString::formatted("From {}", m_fd), level + 1); } RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell) @@ -3366,7 +3366,7 @@ void WriteRedirection::dump(int level) const { Node::dump(level); m_path->dump(level + 1); - print_indented(String::formatted("From {}", m_fd), level + 1); + print_indented(DeprecatedString::formatted("From {}", m_fd), level + 1); } RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell) @@ -3468,7 +3468,7 @@ Value::~Value() { } -String Value::resolve_as_string(RefPtr<Shell> shell) +DeprecatedString Value::resolve_as_string(RefPtr<Shell> shell) { if (shell) shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "Conversion to string not allowed"); @@ -3482,7 +3482,7 @@ Vector<AST::Command> Value::resolve_as_commands(RefPtr<Shell> shell) return { command }; } -ListValue::ListValue(Vector<String> values) +ListValue::ListValue(Vector<DeprecatedString> values) { if (values.is_empty()) return; @@ -3509,9 +3509,9 @@ ListValue::~ListValue() { } -Vector<String> ListValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> ListValue::resolve_as_list(RefPtr<Shell> shell) { - Vector<String> values; + Vector<DeprecatedString> values; for (auto& value : m_contained_values) values.extend(value.resolve_as_list(shell)); @@ -3538,7 +3538,7 @@ CommandSequenceValue::~CommandSequenceValue() { } -Vector<String> CommandSequenceValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> CommandSequenceValue::resolve_as_list(RefPtr<Shell> shell) { shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "Unexpected cast of a command sequence to a list"); return {}; @@ -3549,7 +3549,7 @@ Vector<Command> CommandSequenceValue::resolve_as_commands(RefPtr<Shell>) return m_contained_values; } -Vector<String> CommandValue::resolve_as_list(RefPtr<Shell>) +Vector<DeprecatedString> CommandValue::resolve_as_list(RefPtr<Shell>) { return m_command.argv; } @@ -3567,25 +3567,25 @@ StringValue::~StringValue() { } -String StringValue::resolve_as_string(RefPtr<Shell> shell) +DeprecatedString StringValue::resolve_as_string(RefPtr<Shell> shell) { if (m_split.is_null()) return m_string; return Value::resolve_as_string(shell); } -Vector<String> StringValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> StringValue::resolve_as_list(RefPtr<Shell> shell) { if (is_list()) { auto parts = StringView(m_string).split_view(m_split, m_keep_empty ? SplitBehavior::KeepEmpty : SplitBehavior::Nothing); - Vector<String> result; + Vector<DeprecatedString> result; result.ensure_capacity(parts.size()); for (auto& part : parts) result.append(part); return resolve_slices(shell, move(result), m_slices); } - return { resolve_slices(shell, String { m_string }, m_slices) }; + return { resolve_slices(shell, DeprecatedString { m_string }, m_slices) }; } NonnullRefPtr<Value> StringValue::resolve_without_cast(RefPtr<Shell> shell) @@ -3599,10 +3599,10 @@ NonnullRefPtr<Value> StringValue::resolve_without_cast(RefPtr<Shell> shell) GlobValue::~GlobValue() { } -Vector<String> GlobValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> GlobValue::resolve_as_list(RefPtr<Shell> shell) { if (!shell) - return { resolve_slices(shell, String { m_glob }, m_slices) }; + return { resolve_slices(shell, DeprecatedString { m_glob }, m_slices) }; auto results = shell->expand_globs(m_glob, shell->cwd); if (results.is_empty()) @@ -3614,10 +3614,10 @@ SimpleVariableValue::~SimpleVariableValue() { } -String SimpleVariableValue::resolve_as_string(RefPtr<Shell> shell) +DeprecatedString SimpleVariableValue::resolve_as_string(RefPtr<Shell> shell) { if (!shell) - return resolve_slices(shell, String {}, m_slices); + return resolve_slices(shell, DeprecatedString {}, m_slices); if (auto value = resolve_without_cast(shell); value != this) return value->resolve_as_string(shell); @@ -3626,10 +3626,10 @@ String SimpleVariableValue::resolve_as_string(RefPtr<Shell> shell) return resolve_slices(shell, env_value, m_slices); } -Vector<String> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell) { if (!shell) - return resolve_slices(shell, Vector<String> {}, m_slices); + return resolve_slices(shell, Vector<DeprecatedString> {}, m_slices); if (auto value = resolve_without_cast(shell); value != this) return value->resolve_as_list(shell); @@ -3638,7 +3638,7 @@ Vector<String> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell) if (env_value == nullptr) return { resolve_slices(shell, "", m_slices) }; - return { resolve_slices(shell, String { env_value }, m_slices) }; + return { resolve_slices(shell, DeprecatedString { env_value }, m_slices) }; } NonnullRefPtr<Value> SimpleVariableValue::resolve_without_cast(RefPtr<Shell> shell) @@ -3661,7 +3661,7 @@ SpecialVariableValue::~SpecialVariableValue() { } -String SpecialVariableValue::resolve_as_string(RefPtr<Shell> shell) +DeprecatedString SpecialVariableValue::resolve_as_string(RefPtr<Shell> shell) { if (!shell) return {}; @@ -3676,25 +3676,25 @@ String SpecialVariableValue::resolve_as_string(RefPtr<Shell> shell) return Value::resolve_as_string(shell); } -Vector<String> SpecialVariableValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> SpecialVariableValue::resolve_as_list(RefPtr<Shell> shell) { if (!shell) return {}; switch (m_name) { case '?': - return { resolve_slices(shell, String::number(shell->last_return_code.value_or(0)), m_slices) }; + return { resolve_slices(shell, DeprecatedString::number(shell->last_return_code.value_or(0)), m_slices) }; case '$': - return { resolve_slices(shell, String::number(getpid()), m_slices) }; + return { resolve_slices(shell, DeprecatedString::number(getpid()), m_slices) }; case '*': if (auto argv = shell->lookup_local_variable("ARGV"sv)) return resolve_slices(shell, argv->resolve_as_list(shell), m_slices); - return resolve_slices(shell, Vector<String> {}, m_slices); + return resolve_slices(shell, Vector<DeprecatedString> {}, m_slices); case '#': if (auto argv = shell->lookup_local_variable("ARGV"sv)) { if (argv->is_list()) { auto list_argv = static_cast<AST::ListValue*>(argv.ptr()); - return { resolve_slices(shell, String::number(list_argv->values().size()), m_slices) }; + return { resolve_slices(shell, DeprecatedString::number(list_argv->values().size()), m_slices) }; } return { resolve_slices(shell, "1", m_slices) }; } @@ -3716,12 +3716,12 @@ TildeValue::~TildeValue() { } -String TildeValue::resolve_as_string(RefPtr<Shell> shell) +DeprecatedString TildeValue::resolve_as_string(RefPtr<Shell> shell) { return resolve_as_list(shell).first(); } -Vector<String> TildeValue::resolve_as_list(RefPtr<Shell> shell) +Vector<DeprecatedString> TildeValue::resolve_as_list(RefPtr<Shell> shell) { StringBuilder builder; builder.append('~'); @@ -3744,7 +3744,7 @@ CloseRedirection::~CloseRedirection() ErrorOr<NonnullRefPtr<Rewiring>> PathRedirection::apply() const { - auto check_fd_and_return = [my_fd = this->fd](int fd, String const& path) -> ErrorOr<NonnullRefPtr<Rewiring>> { + auto check_fd_and_return = [my_fd = this->fd](int fd, DeprecatedString const& path) -> ErrorOr<NonnullRefPtr<Rewiring>> { if (fd < 0) { auto error = Error::from_errno(errno); dbgln("open() failed for '{}' with {}", path, error); diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h index 60cdfd0dbb..64ed885db8 100644 --- a/Userland/Shell/AST.h +++ b/Userland/Shell/AST.h @@ -9,11 +9,11 @@ #include "Forward.h" #include "Job.h" #include "NodeVisitor.h" +#include <AK/DeprecatedString.h> #include <AK/Format.h> #include <AK/NonnullRefPtr.h> #include <AK/RefCounted.h> #include <AK/RefPtr.h> -#include <AK/String.h> #include <AK/Types.h> #include <AK/Vector.h> #include <LibLine/Editor.h> @@ -50,7 +50,7 @@ struct Position { }; struct NameWithPosition { - String name; + DeprecatedString name; Position position; }; @@ -107,7 +107,7 @@ private: }; struct PathRedirection : public Redirection { - String path; + DeprecatedString path; int fd { -1 }; enum { Read, @@ -116,7 +116,7 @@ struct PathRedirection : public Redirection { ReadWrite, } direction { Read }; - static NonnullRefPtr<PathRedirection> create(String path, int fd, decltype(direction) direction) + static NonnullRefPtr<PathRedirection> create(DeprecatedString path, int fd, decltype(direction) direction) { return adopt_ref(*new PathRedirection(move(path), fd, direction)); } @@ -125,7 +125,7 @@ struct PathRedirection : public Redirection { virtual ~PathRedirection(); private: - PathRedirection(String path, int fd, decltype(direction) direction) + PathRedirection(DeprecatedString path, int fd, decltype(direction) direction) : path(move(path)) , fd(fd) , direction(direction) @@ -197,7 +197,7 @@ struct NodeWithAction { }; struct Command { - Vector<String> argv; + Vector<DeprecatedString> argv; NonnullRefPtrVector<Redirection> redirections; bool should_wait { true }; bool is_pipe_source { false }; @@ -217,8 +217,8 @@ struct HitTestResult { class Value : public RefCounted<Value> { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) = 0; - virtual String resolve_as_string(RefPtr<Shell> shell); + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) = 0; + virtual DeprecatedString resolve_as_string(RefPtr<Shell> shell); virtual Vector<Command> resolve_as_commands(RefPtr<Shell>); virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) { return *this; } virtual NonnullRefPtr<Value> clone() const = 0; @@ -243,7 +243,7 @@ protected: class CommandValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; virtual Vector<Command> resolve_as_commands(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<CommandValue>(m_command)->set_slices(m_slices); } virtual ~CommandValue(); @@ -253,7 +253,7 @@ public: { } - CommandValue(Vector<String> argv, Position position) + CommandValue(Vector<DeprecatedString> argv, Position position) : m_command({ move(argv), {}, true, false, true, false, nullptr, {}, move(position) }) { } @@ -264,7 +264,7 @@ private: class CommandSequenceValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; virtual Vector<Command> resolve_as_commands(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<CommandSequenceValue>(m_contained_values)->set_slices(m_slices); } virtual ~CommandSequenceValue(); @@ -280,8 +280,8 @@ private: class JobValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override { VERIFY_NOT_REACHED(); } - virtual String resolve_as_string(RefPtr<Shell>) override { return String::formatted("%{}", m_job->job_id()); } + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override { VERIFY_NOT_REACHED(); } + virtual DeprecatedString resolve_as_string(RefPtr<Shell>) override { return DeprecatedString::formatted("%{}", m_job->job_id()); } virtual Vector<Command> resolve_as_commands(RefPtr<Shell>) override { VERIFY_NOT_REACHED(); } virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<JobValue>(m_job)->set_slices(m_slices); } virtual ~JobValue(); @@ -299,13 +299,13 @@ private: class ListValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<ListValue>(m_contained_values)->set_slices(m_slices); } virtual ~ListValue(); virtual bool is_list() const override { return true; } virtual bool is_list_without_resolution() const override { return true; } - ListValue(Vector<String> values); + ListValue(Vector<DeprecatedString> values); ListValue(NonnullRefPtrVector<Value> values) : m_contained_values(move(values)) { @@ -320,14 +320,14 @@ private: class StringValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; - virtual String resolve_as_string(RefPtr<Shell> shell) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; + virtual DeprecatedString resolve_as_string(RefPtr<Shell> shell) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<StringValue>(m_string, m_split, m_keep_empty)->set_slices(m_slices); } virtual ~StringValue(); virtual bool is_string() const override { return m_split.is_null(); } virtual bool is_list() const override { return !m_split.is_null(); } NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override; - StringValue(String string, String split_by = {}, bool keep_empty = false) + StringValue(DeprecatedString string, DeprecatedString split_by = {}, bool keep_empty = false) : m_string(move(string)) , m_split(move(split_by)) , m_keep_empty(keep_empty) @@ -335,48 +335,48 @@ public: } private: - String m_string; - String m_split; + DeprecatedString m_string; + DeprecatedString m_split; bool m_keep_empty { false }; }; class GlobValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<GlobValue>(m_glob, m_generation_position)->set_slices(m_slices); } virtual ~GlobValue(); virtual bool is_glob() const override { return true; } - GlobValue(String glob, Position position) + GlobValue(DeprecatedString glob, Position position) : m_glob(move(glob)) , m_generation_position(move(position)) { } private: - String m_glob; + DeprecatedString m_glob; Position m_generation_position; }; class SimpleVariableValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; - virtual String resolve_as_string(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; + virtual DeprecatedString resolve_as_string(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<SimpleVariableValue>(m_name)->set_slices(m_slices); } virtual ~SimpleVariableValue(); - SimpleVariableValue(String name) + SimpleVariableValue(DeprecatedString name) : m_name(move(name)) { } private: - String m_name; + DeprecatedString m_name; }; class SpecialVariableValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; - virtual String resolve_as_string(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; + virtual DeprecatedString resolve_as_string(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<SpecialVariableValue>(m_name)->set_slices(m_slices); } virtual ~SpecialVariableValue(); @@ -391,18 +391,18 @@ private: class TildeValue final : public Value { public: - virtual Vector<String> resolve_as_list(RefPtr<Shell>) override; - virtual String resolve_as_string(RefPtr<Shell>) override; + virtual Vector<DeprecatedString> resolve_as_list(RefPtr<Shell>) override; + virtual DeprecatedString resolve_as_string(RefPtr<Shell>) override; virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<TildeValue>(m_username)->set_slices(m_slices); } virtual ~TildeValue(); virtual bool is_string() const override { return true; } - TildeValue(String name) + TildeValue(DeprecatedString name) : m_username(move(name)) { } private: - String m_username; + DeprecatedString m_username; }; class Node : public RefCounted<Node> { @@ -422,7 +422,7 @@ public: return { this, nullptr, nullptr }; return { nullptr, nullptr, nullptr }; } - virtual String class_name() const { return "Node"; } + virtual DeprecatedString class_name() const { return "Node"; } Node(Position); virtual ~Node() = default; @@ -509,14 +509,14 @@ protected: RefPtr<SyntaxError> m_syntax_error_node; }; -#define NODE(name) \ - virtual String class_name() const override \ - { \ - return #name; \ - } \ - virtual Kind kind() const override \ - { \ - return Kind::name; \ +#define NODE(name) \ + virtual DeprecatedString class_name() const override \ + { \ + return #name; \ + } \ + virtual Kind kind() const override \ + { \ + return Kind::name; \ } class PathRedirectionNode : public Node { @@ -600,11 +600,11 @@ private: class BarewordLiteral final : public Node { public: - BarewordLiteral(Position, String); + BarewordLiteral(Position, DeprecatedString); virtual ~BarewordLiteral() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& text() const { return m_text; } + DeprecatedString const& text() const { return m_text; } private: NODE(BarewordLiteral); @@ -614,7 +614,7 @@ private: virtual bool is_bareword() const override { return true; } virtual RefPtr<Node> leftmost_trivial_literal() const override { return this; } - String m_text; + DeprecatedString m_text; }; class BraceExpansion final : public Node { @@ -717,11 +717,11 @@ private: class Comment : public Node { public: - Comment(Position, String); + Comment(Position, DeprecatedString); virtual ~Comment(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& text() const { return m_text; } + DeprecatedString const& text() const { return m_text; } private: NODE(Comment); @@ -729,7 +729,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - String m_text; + DeprecatedString m_text; }; class ContinuationControl final : public Node { @@ -880,11 +880,11 @@ private: class Glob final : public Node { public: - Glob(Position, String); + Glob(Position, DeprecatedString); virtual ~Glob(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& text() const { return m_text; } + DeprecatedString const& text() const { return m_text; } private: NODE(Glob); @@ -894,7 +894,7 @@ private: virtual bool is_glob() const override { return true; } virtual bool is_list() const override { return true; } - String m_text; + DeprecatedString m_text; }; struct HistorySelector { @@ -913,7 +913,7 @@ struct HistorySelector { EventKind kind { IndexFromStart }; size_t index { 0 }; Position text_position; - String text; + DeprecatedString text; } event; struct WordSelector { @@ -1014,7 +1014,7 @@ public: NonnullRefPtrVector<Node> const& arguments() const { return m_arguments; } auto const& function() const { return m_function; } - String const& function_name() const { return m_function.name; } + DeprecatedString const& function_name() const { return m_function.name; } Position const& function_position() const { return m_function.position; } bool has_closing_brace() const { return m_closing_brace_position.has_value(); } @@ -1056,7 +1056,7 @@ private: struct MatchEntry { Variant<NonnullRefPtrVector<Node>, Vector<Regex<ECMA262>>> options; - Optional<Vector<String>> match_names; + Optional<Vector<DeprecatedString>> match_names; Optional<Position> match_as_position; Vector<Position> pipe_positions; RefPtr<Node> body; @@ -1064,12 +1064,12 @@ struct MatchEntry { class MatchExpr final : public Node { public: - MatchExpr(Position, NonnullRefPtr<Node> expr, String name, Optional<Position> as_position, Vector<MatchEntry> entries); + MatchExpr(Position, NonnullRefPtr<Node> expr, DeprecatedString name, Optional<Position> as_position, Vector<MatchEntry> entries); virtual ~MatchExpr(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } NonnullRefPtr<Node> const& matched_expr() const { return m_matched_expr; } - String const& expr_name() const { return m_expr_name; } + DeprecatedString const& expr_name() const { return m_expr_name; } Vector<MatchEntry> const& entries() const { return m_entries; } Optional<Position> const& as_position() const { return m_as_position; } @@ -1083,7 +1083,7 @@ private: virtual bool should_override_execution_in_current_process() const override { return true; } NonnullRefPtr<Node> m_matched_expr; - String m_expr_name; + DeprecatedString m_expr_name; Optional<Position> m_as_position; Vector<MatchEntry> m_entries; }; @@ -1262,11 +1262,11 @@ protected: class SimpleVariable final : public VariableNode { public: - SimpleVariable(Position, String); + SimpleVariable(Position, DeprecatedString); virtual ~SimpleVariable(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& name() const { return m_name; } + DeprecatedString const& name() const { return m_name; } private: NODE(SimpleVariable); @@ -1277,7 +1277,7 @@ private: virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_simple_variable() const override { return true; } - String m_name; + DeprecatedString m_name; }; class SpecialVariable final : public VariableNode { @@ -1322,11 +1322,11 @@ private: class Heredoc final : public Node { public: - Heredoc(Position, String end, bool allow_interpolation, bool deindent); + Heredoc(Position, DeprecatedString end, bool allow_interpolation, bool deindent); virtual ~Heredoc(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& end() const { return m_end; } + DeprecatedString const& end() const { return m_end; } bool allow_interpolation() const { return m_allows_interpolation; } bool deindent() const { return m_deindent; } RefPtr<AST::Node> const& contents() const { return m_contents; } @@ -1347,7 +1347,7 @@ private: virtual HitTestResult hit_test_position(size_t) const override; virtual RefPtr<Node> leftmost_trivial_literal() const override { return this; }; - String m_end; + DeprecatedString m_end; bool m_allows_interpolation { false }; bool m_deindent { false }; RefPtr<AST::Node> m_contents; @@ -1361,11 +1361,11 @@ public: DoubleQuotes, }; - StringLiteral(Position, String, EnclosureType); + StringLiteral(Position, DeprecatedString, EnclosureType); virtual ~StringLiteral(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& text() const { return m_text; } + DeprecatedString const& text() const { return m_text; } EnclosureType enclosure_type() const { return m_enclosure_type; } private: @@ -1375,7 +1375,7 @@ private: virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual RefPtr<Node> leftmost_trivial_literal() const override { return this; }; - String m_text; + DeprecatedString m_text; EnclosureType m_enclosure_type; }; @@ -1401,11 +1401,11 @@ private: class SyntaxError final : public Node { public: - SyntaxError(Position, String, bool is_continuable = false); + SyntaxError(Position, DeprecatedString, bool is_continuable = false); virtual ~SyntaxError(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String const& error_text() const { return m_syntax_error_text; } + DeprecatedString const& error_text() const { return m_syntax_error_text; } bool is_continuable() const { return m_is_continuable; } virtual void clear_syntax_error() override @@ -1430,7 +1430,7 @@ private: virtual HitTestResult hit_test_position(size_t) const override { return { nullptr, nullptr, nullptr }; } virtual SyntaxError const& syntax_error_node() const override; - String m_syntax_error_text; + DeprecatedString m_syntax_error_text; bool m_is_continuable { false }; bool m_is_cleared { false }; }; @@ -1454,11 +1454,11 @@ private: class Tilde final : public Node { public: - Tilde(Position, String); + Tilde(Position, DeprecatedString); virtual ~Tilde(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - String text() const; + DeprecatedString text() const; private: NODE(Tilde); @@ -1469,7 +1469,7 @@ private: virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_tilde() const override { return true; } - String m_username; + DeprecatedString m_username; }; class VariableDeclarations final : public Node { diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index df14ea521b..15b8f906ef 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -7,10 +7,10 @@ #include "AST.h" #include "Shell.h" #include "Shell/Formatter.h" +#include <AK/DeprecatedString.h> #include <AK/LexicalPath.h> #include <AK/ScopeGuard.h> #include <AK/Statistics.h> -#include <AK/String.h> #include <LibCore/ArgsParser.h> #include <LibCore/EventLoop.h> #include <LibCore/File.h> @@ -41,7 +41,7 @@ int Shell::builtin_dump(int argc, char const** argv) int Shell::builtin_alias(int argc, char const** argv) { - Vector<String> arguments; + Vector<DeprecatedString> arguments; Core::ArgsParser parser; parser.add_positional_argument(arguments, "List of name[=values]'s", "name[=value]", Core::ArgsParser::Required::No); @@ -77,7 +77,7 @@ int Shell::builtin_alias(int argc, char const** argv) int Shell::builtin_unalias(int argc, char const** argv) { bool remove_all { false }; - Vector<String> arguments; + Vector<DeprecatedString> arguments; Core::ArgsParser parser; parser.set_general_help("Remove alias from the list of aliases"); @@ -180,7 +180,7 @@ int Shell::builtin_bg(int argc, char const** argv) int Shell::builtin_type(int argc, char const** argv) { - Vector<String> commands; + Vector<DeprecatedString> commands; bool dont_show_function_source = false; Core::ArgsParser parser; @@ -257,7 +257,7 @@ int Shell::builtin_cd(int argc, char const** argv) if (!parser.parse(argc, const_cast<char**>(argv), Core::ArgsParser::FailureBehavior::PrintUsage)) return 1; - String new_path; + DeprecatedString new_path; if (!arg_path) { new_path = home; @@ -342,7 +342,7 @@ int Shell::builtin_dirs(int argc, char const** argv) bool number_when_printing = false; char separator = ' '; - Vector<String> paths; + Vector<DeprecatedString> paths; Core::ArgsParser parser; parser.add_option(clear, "Clear the directory stack", "clear", 'c'); @@ -426,7 +426,7 @@ int Shell::builtin_exit(int argc, char const** argv) int Shell::builtin_export(int argc, char const** argv) { - Vector<String> vars; + Vector<DeprecatedString> vars; Core::ArgsParser parser; parser.add_positional_argument(vars, "List of variable[=value]'s", "values", Core::ArgsParser::Required::No); @@ -472,7 +472,7 @@ int Shell::builtin_export(int argc, char const** argv) int Shell::builtin_glob(int argc, char const** argv) { - Vector<String> globs; + Vector<DeprecatedString> globs; Core::ArgsParser parser; parser.add_positional_argument(globs, "Globs to resolve", "glob"); @@ -704,8 +704,8 @@ int Shell::builtin_pushd(int argc, char const** argv) return 1; } - String dir1 = directory_stack.take_first(); - String dir2 = directory_stack.take_first(); + DeprecatedString dir1 = directory_stack.take_first(); + DeprecatedString dir2 = directory_stack.take_first(); directory_stack.insert(0, dir2); directory_stack.insert(1, dir1); @@ -855,7 +855,7 @@ int Shell::builtin_shift(int argc, char const** argv) int Shell::builtin_source(int argc, char const** argv) { char const* file_to_source = nullptr; - Vector<String> args; + Vector<DeprecatedString> args; Core::ArgsParser parser; parser.add_positional_argument(file_to_source, "File to read commands from", "path"); @@ -919,7 +919,7 @@ int Shell::builtin_time(int argc, char const** argv) warnln("Timing report: {} ms", iteration_times.sum()); warnln("=============="); - warnln("Command: {}", String::join(' ', Span<char const*>(argv, argc))); + warnln("Command: {}", DeprecatedString::join(' ', Span<char const*>(argv, argc))); warnln("Average time: {:.2} ms (median: {}, stddev: {:.2}, min: {}, max:{})", iteration_times.average(), iteration_times.median(), iteration_times.standard_deviation(), @@ -1021,7 +1021,7 @@ int Shell::builtin_wait(int argc, char const** argv) int Shell::builtin_unset(int argc, char const** argv) { - Vector<String> vars; + Vector<DeprecatedString> vars; Core::ArgsParser parser; parser.add_positional_argument(vars, "List of variables", "variables", Core::ArgsParser::Required::Yes); @@ -1074,7 +1074,7 @@ int Shell::builtin_not(int argc, char const** argv) int Shell::builtin_kill(int argc, char const** argv) { // Simply translate the arguments and pass them to `kill' - Vector<String> replaced_values; + Vector<DeprecatedString> replaced_values; auto kill_path = Core::File::resolve_executable_from_environment("kill"sv); if (!kill_path.has_value()) { warnln("kill: `kill' not found in PATH"); @@ -1085,7 +1085,7 @@ int Shell::builtin_kill(int argc, char const** argv) if (auto job_id = resolve_job_spec({ argv[i], strlen(argv[1]) }); job_id.has_value()) { auto job = find_job(job_id.value()); if (job) { - replaced_values.append(String::number(job->pid())); + replaced_values.append(DeprecatedString::number(job->pid())); } else { warnln("kill: Job with pid {} not found", job_id.value()); return 1; @@ -1177,7 +1177,7 @@ int Shell::builtin_argsparser_parse(int argc, char const** argv) Vector<char const*> arguments; Variant<Core::ArgsParser::Option, Core::ArgsParser::Arg, Empty> current; - String current_variable; + DeprecatedString current_variable; // if max > 1 or min < 1, or explicit `--list`. bool treat_arg_as_list = false; enum class Type { @@ -1199,19 +1199,19 @@ int Shell::builtin_argsparser_parse(int argc, char const** argv) return AST::make_ref_counted<AST::StringValue>(value); case Type::I32: if (auto number = value.to_int(); number.has_value()) - return AST::make_ref_counted<AST::StringValue>(String::number(*number)); + return AST::make_ref_counted<AST::StringValue>(DeprecatedString::number(*number)); warnln("Invalid value for type i32: {}", value); return {}; case Type::U32: case Type::Size: if (auto number = value.to_uint(); number.has_value()) - return AST::make_ref_counted<AST::StringValue>(String::number(*number)); + return AST::make_ref_counted<AST::StringValue>(DeprecatedString::number(*number)); warnln("Invalid value for type u32|size: {}", value); return {}; case Type::Double: { - String string = value; + DeprecatedString string = value; char* endptr = nullptr; auto number = strtod(string.characters(), &endptr); if (endptr != string.characters() + string.length()) { @@ -1219,7 +1219,7 @@ int Shell::builtin_argsparser_parse(int argc, char const** argv) return {}; } - return AST::make_ref_counted<AST::StringValue>(String::number(number)); + return AST::make_ref_counted<AST::StringValue>(DeprecatedString::number(number)); } default: VERIFY_NOT_REACHED(); diff --git a/Userland/Shell/Execution.h b/Userland/Shell/Execution.h index 02af16738c..681d908405 100644 --- a/Userland/Shell/Execution.h +++ b/Userland/Shell/Execution.h @@ -7,9 +7,9 @@ #pragma once #include "Forward.h" +#include <AK/DeprecatedString.h> #include <AK/Forward.h> #include <AK/NonnullRefPtrVector.h> -#include <AK/String.h> #include <AK/Vector.h> #include <LibCore/ElapsedTimer.h> diff --git a/Userland/Shell/Formatter.cpp b/Userland/Shell/Formatter.cpp index 54d4686482..f291d72750 100644 --- a/Userland/Shell/Formatter.cpp +++ b/Userland/Shell/Formatter.cpp @@ -13,14 +13,14 @@ namespace Shell { -String Formatter::format() +DeprecatedString Formatter::format() { auto node = m_root_node ? m_root_node : Parser(m_source).parse(); if (m_cursor >= 0) m_output_cursor = m_cursor; if (!node) - return String(); + return DeprecatedString(); if (node->is_syntax_error()) return m_source; @@ -66,7 +66,7 @@ void Formatter::in_new_block(Function<void()> callback) current_builder().append('}'); } -String Formatter::in_new_builder(Function<void()> callback, StringBuilder new_builder) +DeprecatedString Formatter::in_new_builder(Function<void()> callback, StringBuilder new_builder) { m_builders.append(move(new_builder)); callback(); diff --git a/Userland/Shell/Formatter.h b/Userland/Shell/Formatter.h index 1a08790cf2..9cb6bfbc18 100644 --- a/Userland/Shell/Formatter.h +++ b/Userland/Shell/Formatter.h @@ -7,8 +7,8 @@ #pragma once #include "NodeVisitor.h" +#include <AK/DeprecatedString.h> #include <AK/Forward.h> -#include <AK/String.h> #include <AK/StringBuilder.h> #include <AK/StringView.h> #include <AK/Types.h> @@ -41,7 +41,7 @@ public: { } - String format(); + DeprecatedString format(); size_t cursor() const { return m_output_cursor; } private: @@ -97,7 +97,7 @@ private: ALWAYS_INLINE void with_added_indent(int indent, Function<void()>); ALWAYS_INLINE void in_new_block(Function<void()>); - ALWAYS_INLINE String in_new_builder(Function<void()>, StringBuilder new_builder = StringBuilder {}); + ALWAYS_INLINE DeprecatedString in_new_builder(Function<void()>, StringBuilder new_builder = StringBuilder {}); StringBuilder& current_builder() { return m_builders.last(); } @@ -123,7 +123,7 @@ private: const AST::Node* m_last_visited_node { nullptr }; StringView m_trivia; - Vector<String> m_heredocs_to_append_after_sequence; + Vector<DeprecatedString> m_heredocs_to_append_after_sequence; }; } diff --git a/Userland/Shell/ImmediateFunctions.cpp b/Userland/Shell/ImmediateFunctions.cpp index 081a35c301..5771058e2d 100644 --- a/Userland/Shell/ImmediateFunctions.cpp +++ b/Userland/Shell/ImmediateFunctions.cpp @@ -14,7 +14,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin { auto name = across ? "length_across" : "length"; if (arguments.size() < 1 || arguments.size() > 2) { - raise_error(ShellError::EvaluatedSyntaxError, String::formatted("Expected one or two arguments to `{}'", name), invoking_node.position()); + raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected one or two arguments to `{}'", name), invoking_node.position()); return nullptr; } @@ -33,7 +33,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin auto& mode_arg = arguments.first(); if (!mode_arg.is_bareword()) { - raise_error(ShellError::EvaluatedSyntaxError, String::formatted("Expected a bareword (either 'string' or 'list') in the two-argument form of the `{}' immediate", name), mode_arg.position()); + raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected a bareword (either 'string' or 'list') in the two-argument form of the `{}' immediate", name), mode_arg.position()); return nullptr; } @@ -45,7 +45,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin } else if (mode_name == "infer") { mode = Infer; } else { - raise_error(ShellError::EvaluatedSyntaxError, String::formatted("Expected either 'string' or 'list' (and not {}) in the two-argument form of the `{}' immediate", mode_name, name), mode_arg.position()); + raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected either 'string' or 'list' (and not {}) in the two-argument form of the `{}' immediate", mode_name, name), mode_arg.position()); return nullptr; } @@ -67,7 +67,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin } auto value_with_number = [&](auto number) -> NonnullRefPtr<AST::Node> { - return AST::make_ref_counted<AST::BarewordLiteral>(invoking_node.position(), String::number(number)); + return AST::make_ref_counted<AST::BarewordLiteral>(invoking_node.position(), DeprecatedString::number(number)); }; auto do_across = [&](StringView mode_name, auto& values) { @@ -126,7 +126,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin if (is_inferred) { raise_error(ShellError::EvaluatedSyntaxError, - String::formatted("Could not infer expression type, please explicitly use `{0} string' or `{0} list'", name), + DeprecatedString::formatted("Could not infer expression type, please explicitly use `{0} string' or `{0} list'", name), invoking_node.position()); return nullptr; } @@ -135,7 +135,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin raise_error(ShellError::EvaluatedSyntaxError, source.is_empty() ? "Invalid application of `length' to a list" - : String::formatted("Invalid application of `length' to a list\nperhaps you meant `{1}length \"{0}\"{2}' or `{1}length_across {0}{2}'?", source, "\x1b[32m", "\x1b[0m"), + : DeprecatedString::formatted("Invalid application of `length' to a list\nperhaps you meant `{1}length \"{0}\"{2}' or `{1}length_across {0}{2}'?", source, "\x1b[32m", "\x1b[0m"), expr_node->position()); return nullptr; } @@ -159,7 +159,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin auto source = formatter.format(); raise_error(ShellError::EvaluatedSyntaxError, - String::formatted("Invalid application of `length_across' to a non-list\nperhaps you meant `{1}length {0}{2}'?", source, "\x1b[32m", "\x1b[0m"), + DeprecatedString::formatted("Invalid application of `length_across' to a non-list\nperhaps you meant `{1}length {0}{2}'?", source, "\x1b[32m", "\x1b[0m"), expr_node->position()); return nullptr; } @@ -340,7 +340,7 @@ RefPtr<AST::Node> Shell::immediate_split(AST::ImmediateExpression& invoking_node return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), NonnullRefPtrVector<AST::Node> {}); auto& value = list.first(); - Vector<String> split_strings; + Vector<DeprecatedString> split_strings; if (delimiter_str.is_empty()) { StringBuilder builder; for (auto code_point : Utf8View { value }) { @@ -462,7 +462,7 @@ RefPtr<AST::Node> Shell::run_immediate_function(StringView str, AST::ImmediateEx ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() #undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION - raise_error(ShellError::EvaluatedSyntaxError, String::formatted("Unknown immediate function {}", str), invoking_node.position()); + raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Unknown immediate function {}", str), invoking_node.position()); return nullptr; } diff --git a/Userland/Shell/Job.cpp b/Userland/Shell/Job.cpp index c1a1a0b1a3..171018b8ec 100644 --- a/Userland/Shell/Job.cpp +++ b/Userland/Shell/Job.cpp @@ -63,7 +63,7 @@ bool Job::print_status(PrintStatusMode mode) return true; } -Job::Job(pid_t pid, unsigned pgid, String cmd, u64 job_id, AST::Command&& command) +Job::Job(pid_t pid, unsigned pgid, DeprecatedString cmd, u64 job_id, AST::Command&& command) : m_pgid(pgid) , m_pid(pid) , m_job_id(job_id) diff --git a/Userland/Shell/Job.h b/Userland/Shell/Job.h index a92c9577dc..6f214f1fb4 100644 --- a/Userland/Shell/Job.h +++ b/Userland/Shell/Job.h @@ -9,11 +9,11 @@ #include "Execution.h" #include "Forward.h" #include <AK/Debug.h> +#include <AK/DeprecatedString.h> #include <AK/Function.h> #include <AK/JsonObject.h> #include <AK/JsonValue.h> #include <AK/OwnPtr.h> -#include <AK/String.h> #include <LibCore/ElapsedTimer.h> #include <LibCore/Object.h> @@ -23,7 +23,7 @@ struct LocalFrame; class Job : public RefCounted<Job> { public: - static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt_ref(*new Job(pid, pgid, move(cmd), job_id, move(command))); } + static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, DeprecatedString cmd, u64 job_id, AST::Command&& command) { return adopt_ref(*new Job(pid, pgid, move(cmd), job_id, move(command))); } ~Job() { @@ -40,7 +40,7 @@ public: pid_t pgid() const { return m_pgid; } pid_t pid() const { return m_pid; } - String const& cmd() const { return m_cmd; } + DeprecatedString const& cmd() const { return m_cmd; } const AST::Command& command() const { return *m_command; } AST::Command* command_ptr() { return m_command; } u64 job_id() const { return m_job_id; } @@ -92,12 +92,12 @@ public: bool print_status(PrintStatusMode); private: - Job(pid_t pid, unsigned pgid, String cmd, u64 job_id, AST::Command&& command); + Job(pid_t pid, unsigned pgid, DeprecatedString cmd, u64 job_id, AST::Command&& command); pid_t m_pgid { 0 }; pid_t m_pid { 0 }; u64 m_job_id { 0 }; - String m_cmd; + DeprecatedString m_cmd; bool m_exited { false }; bool m_running_in_background { false }; bool m_should_announce_exit { false }; diff --git a/Userland/Shell/Parser.cpp b/Userland/Shell/Parser.cpp index b6eb1d8444..72907c8408 100644 --- a/Userland/Shell/Parser.cpp +++ b/Userland/Shell/Parser.cpp @@ -858,12 +858,12 @@ RefPtr<AST::Node> Parser::parse_match_expr() if (!match_expression) { return create<AST::MatchExpr>( create<AST::SyntaxError>("Expected an expression after 'match'", true), - String {}, Optional<AST::Position> {}, Vector<AST::MatchEntry> {}); + DeprecatedString {}, Optional<AST::Position> {}, Vector<AST::MatchEntry> {}); } consume_while(is_any_of(" \t\n"sv)); - String match_name; + DeprecatedString match_name; Optional<AST::Position> as_position; auto as_start = m_offset; auto as_line = line(); @@ -873,7 +873,7 @@ RefPtr<AST::Node> Parser::parse_match_expr() if (consume_while(is_any_of(" \t\n"sv)).is_empty()) { auto node = create<AST::MatchExpr>( match_expression.release_nonnull(), - String {}, move(as_position), Vector<AST::MatchEntry> {}); + DeprecatedString {}, move(as_position), Vector<AST::MatchEntry> {}); node->set_is_syntax_error(create<AST::SyntaxError>("Expected whitespace after 'as' in 'match'", true)); return node; } @@ -882,7 +882,7 @@ RefPtr<AST::Node> Parser::parse_match_expr() if (match_name.is_empty()) { auto node = create<AST::MatchExpr>( match_expression.release_nonnull(), - String {}, move(as_position), Vector<AST::MatchEntry> {}); + DeprecatedString {}, move(as_position), Vector<AST::MatchEntry> {}); node->set_is_syntax_error(create<AST::SyntaxError>("Expected an identifier after 'as' in 'match'", true)); return node; } @@ -930,7 +930,7 @@ AST::MatchEntry Parser::parse_match_entry() NonnullRefPtrVector<AST::Node> patterns; Vector<Regex<ECMA262>> regexps; Vector<AST::Position> pipe_positions; - Optional<Vector<String>> match_names; + Optional<Vector<DeprecatedString>> match_names; Optional<AST::Position> match_as_position; enum { Regex, @@ -1001,7 +1001,7 @@ AST::MatchEntry Parser::parse_match_entry() if (!error) error = create<AST::SyntaxError>("Expected an explicit list of identifiers after a pattern 'as'"); } else { - match_names = Vector<String>(); + match_names = Vector<DeprecatedString>(); for (;;) { consume_while(is_whitespace); auto name = consume_while(is_word_character); @@ -1019,7 +1019,7 @@ AST::MatchEntry Parser::parse_match_entry() } if (pattern_kind == Regex) { - Vector<String> names; + Vector<DeprecatedString> names; for (auto& regex : regexps) { if (names.is_empty()) { for (auto& name : regex.parser_result.capture_groups) @@ -1226,7 +1226,7 @@ RefPtr<AST::Node> Parser::parse_expression() { auto rule_start = push_start(); if (m_rule_start_offsets.size() > max_allowed_nested_rule_depth) - return create<AST::SyntaxError>(String::formatted("Expression nested too deep (max allowed is {})", max_allowed_nested_rule_depth)); + return create<AST::SyntaxError>(DeprecatedString::formatted("Expression nested too deep (max allowed is {})", max_allowed_nested_rule_depth)); auto starting_char = peek(); @@ -1897,7 +1897,7 @@ RefPtr<AST::Node> Parser::parse_bareword() auto current_line = line(); auto string = builder.to_string(); if (string.starts_with('~')) { - String username; + DeprecatedString username; RefPtr<AST::Node> tilde, text; auto first_slash_index = string.find('/'); @@ -1963,7 +1963,7 @@ RefPtr<AST::Node> Parser::parse_glob() } else { // FIXME: Allow composition of tilde+bareword with globs: '~/foo/bar/baz*' restore_to(saved_offset.offset, saved_offset.line); - bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Unexpected {} inside a glob", bareword_part->class_name()))); + bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(DeprecatedString::formatted("Unexpected {} inside a glob", bareword_part->class_name()))); return bareword_part; } textbuilder.append(text); @@ -1984,7 +1984,7 @@ RefPtr<AST::Node> Parser::parse_glob() textbuilder.append('~'); textbuilder.append(bareword->text()); } else { - return create<AST::SyntaxError>(String::formatted("Invalid node '{}' in glob position, escape shell special characters", glob_after->class_name())); + return create<AST::SyntaxError>(DeprecatedString::formatted("Invalid node '{}' in glob position, escape shell special characters", glob_after->class_name())); } } @@ -2093,7 +2093,7 @@ RefPtr<AST::Node> Parser::parse_heredoc_initiation_record() // StringLiteral | bareword if (auto bareword = parse_bareword()) { if (!bareword->is_bareword()) { - syntax_error_node = create<AST::SyntaxError>(String::formatted("Expected a bareword or a quoted string, not {}", bareword->class_name())); + syntax_error_node = create<AST::SyntaxError>(DeprecatedString::formatted("Expected a bareword or a quoted string, not {}", bareword->class_name())); } else { if (bareword->is_syntax_error()) syntax_error_node = bareword->syntax_error_node(); @@ -2121,7 +2121,7 @@ RefPtr<AST::Node> Parser::parse_heredoc_initiation_record() if (syntax_error_node) node->set_is_syntax_error(*syntax_error_node); else - node->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Expected heredoc contents for heredoc with end key '{}'", node->end()), true)); + node->set_is_syntax_error(*create<AST::SyntaxError>(DeprecatedString::formatted("Expected heredoc contents for heredoc with end key '{}'", node->end()), true)); record.node = node; m_heredoc_initiations.append(move(record)); @@ -2137,7 +2137,7 @@ bool Parser::parse_heredoc_entries() for (auto& record : heredocs) { auto rule_start = push_start(); if (m_rule_start_offsets.size() > max_allowed_nested_rule_depth) { - record.node->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Expression nested too deep (max allowed is {})", max_allowed_nested_rule_depth))); + record.node->set_is_syntax_error(*create<AST::SyntaxError>(DeprecatedString::formatted("Expression nested too deep (max allowed is {})", max_allowed_nested_rule_depth))); continue; } bool found_key = false; @@ -2164,7 +2164,7 @@ bool Parser::parse_heredoc_entries() // Now just wrap it in a StringLiteral and set it as the node's contents auto node = create<AST::StringLiteral>(m_input.substring_view(rule_start->offset, last_line_offset->offset - rule_start->offset), AST::StringLiteral::EnclosureType::None); if (!found_key) - node->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Expected to find the heredoc key '{}', but found Eof", record.end), true)); + node->set_is_syntax_error(*create<AST::SyntaxError>(DeprecatedString::formatted("Expected to find the heredoc key '{}', but found Eof", record.end), true)); record.node->set_contents(move(node)); } else { // Interpolation is allowed, so we're going to read doublequoted string innards @@ -2213,9 +2213,9 @@ bool Parser::parse_heredoc_entries() if (!expr && found_key) { expr = create<AST::StringLiteral>("", AST::StringLiteral::EnclosureType::None); } else if (!expr) { - expr = create<AST::SyntaxError>(String::formatted("Expected to find a valid string inside a heredoc (with end key '{}')", record.end), true); + expr = create<AST::SyntaxError>(DeprecatedString::formatted("Expected to find a valid string inside a heredoc (with end key '{}')", record.end), true); } else if (!found_key) { - expr->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Expected to find the heredoc key '{}'", record.end), true)); + expr->set_is_syntax_error(*create<AST::SyntaxError>(DeprecatedString::formatted("Expected to find the heredoc key '{}'", record.end), true)); } record.node->set_contents(create<AST::DoubleQuotedString>(move(expr))); diff --git a/Userland/Shell/Parser.h b/Userland/Shell/Parser.h index 802489d9b0..91da805da4 100644 --- a/Userland/Shell/Parser.h +++ b/Userland/Shell/Parser.h @@ -7,9 +7,9 @@ #pragma once #include "AST.h" +#include <AK/DeprecatedString.h> #include <AK/Function.h> #include <AK/RefPtr.h> -#include <AK/String.h> #include <AK/StringBuilder.h> #include <AK/Vector.h> @@ -53,7 +53,7 @@ private: }; struct HeredocInitiationRecord { - String end; + DeprecatedString end; RefPtr<AST::Heredoc> node; bool interpolate { false }; bool deindent { false }; diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 6465607777..a3ec796085 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -76,9 +76,9 @@ void Shell::print_path(StringView path) out("\033]8;;{}\033\\{}\033]8;;\033\\", url.serialize(), path); } -String Shell::prompt() const +DeprecatedString Shell::prompt() const { - auto build_prompt = [&]() -> String { + auto build_prompt = [&]() -> DeprecatedString { auto* ps1 = getenv("PROMPT"); if (!ps1) { if (uid == 0) @@ -113,7 +113,7 @@ String Shell::prompt() const builder.append({ hostname, strlen(hostname) }); break; case 'w': { - String home_path = getenv("HOME"); + DeprecatedString home_path = getenv("HOME"); if (cwd.starts_with(home_path)) { builder.append('~'); builder.append(cwd.substring_view(home_path.length(), cwd.length() - home_path.length())); @@ -136,7 +136,7 @@ String Shell::prompt() const return build_prompt(); } -String Shell::expand_tilde(StringView expression) +DeprecatedString Shell::expand_tilde(StringView expression) { VERIFY(expression.starts_with('~')); @@ -159,9 +159,9 @@ String Shell::expand_tilde(StringView expression) if (!home) { auto passwd = getpwuid(getuid()); VERIFY(passwd && passwd->pw_dir); - return String::formatted("{}/{}", passwd->pw_dir, path.to_string()); + return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_string()); } - return String::formatted("{}/{}", home, path.to_string()); + return DeprecatedString::formatted("{}/{}", home, path.to_string()); } auto passwd = getpwnam(login_name.to_string().characters()); @@ -169,7 +169,7 @@ String Shell::expand_tilde(StringView expression) return expression; VERIFY(passwd->pw_dir); - return String::formatted("{}/{}", passwd->pw_dir, path.to_string()); + return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_string()); } bool Shell::is_glob(StringView s) @@ -204,7 +204,7 @@ Vector<StringView> Shell::split_path(StringView path) return parts; } -Vector<String> Shell::expand_globs(StringView path, StringView base) +Vector<DeprecatedString> Shell::expand_globs(StringView path, StringView base) { auto explicitly_set_base = false; if (path.starts_with('/')) { @@ -212,7 +212,7 @@ Vector<String> Shell::expand_globs(StringView path, StringView base) explicitly_set_base = true; } auto parts = split_path(path); - String base_string = base; + DeprecatedString base_string = base; struct stat statbuf; if (lstat(base_string.characters(), &statbuf) < 0) { perror("lstat"); @@ -242,10 +242,10 @@ Vector<String> Shell::expand_globs(StringView path, StringView base) return results; } -Vector<String> Shell::expand_globs(Vector<StringView> path_segments, StringView base) +Vector<DeprecatedString> Shell::expand_globs(Vector<StringView> path_segments, StringView base) { if (path_segments.is_empty()) { - String base_str = base; + DeprecatedString base_str = base; struct stat statbuf; if (lstat(base_str.characters(), &statbuf) < 0) return {}; @@ -254,14 +254,14 @@ Vector<String> Shell::expand_globs(Vector<StringView> path_segments, StringView auto first_segment = path_segments.take_first(); if (is_glob(first_segment)) { - Vector<String> result; + Vector<DeprecatedString> result; Core::DirIterator di(base, Core::DirIterator::SkipParentAndBaseDir); if (di.has_error()) return {}; while (di.has_next()) { - String path = di.next_path(); + DeprecatedString path = di.next_path(); // Dotfiles have to be explicitly requested if (path[0] == '.' && first_segment[0] != '.') @@ -332,10 +332,10 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands return commands; } -String Shell::resolve_path(String path) const +DeprecatedString Shell::resolve_path(DeprecatedString path) const { if (!path.starts_with('/')) - path = String::formatted("{}/{}", cwd, path); + path = DeprecatedString::formatted("{}/{}", cwd, path); return Core::File::real_path_for(path); } @@ -385,7 +385,7 @@ RefPtr<AST::Value> Shell::get_argument(size_t index) const return nullptr; } -String Shell::local_variable_or(StringView name, String const& replacement) const +DeprecatedString Shell::local_variable_or(StringView name, DeprecatedString const& replacement) const { auto value = lookup_local_variable(name); if (value) { @@ -396,7 +396,7 @@ String Shell::local_variable_or(StringView name, String const& replacement) cons return replacement; } -void Shell::set_local_variable(String const& name, RefPtr<AST::Value> value, bool only_in_current_frame) +void Shell::set_local_variable(DeprecatedString const& name, RefPtr<AST::Value> value, bool only_in_current_frame) { if (!only_in_current_frame) { if (auto* frame = find_frame_containing_local_variable(name)) { @@ -419,7 +419,7 @@ void Shell::unset_local_variable(StringView name, bool only_in_current_frame) m_local_frames.last().local_variables.remove(name); } -void Shell::define_function(String name, Vector<String> argnames, RefPtr<AST::Node> body) +void Shell::define_function(DeprecatedString name, Vector<DeprecatedString> argnames, RefPtr<AST::Node> body) { add_entry_to_cache({ RunnablePath::Kind::Function, name }); m_functions.set(name, { name, move(argnames), move(body) }); @@ -437,7 +437,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval) StringView name = command.argv.first(); - TemporaryChange<String> script_change { current_script, name }; + TemporaryChange<DeprecatedString> script_change { current_script, name }; auto function_option = m_functions.get(name); if (!function_option.has_value()) @@ -451,12 +451,12 @@ bool Shell::invoke_function(const AST::Command& command, int& retval) } if (command.argv.size() - 1 < function.arguments.size()) { - raise_error(ShellError::EvaluatedSyntaxError, String::formatted("Expected at least {} arguments to {}, but got {}", function.arguments.size(), function.name, command.argv.size() - 1), command.position); + raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected at least {} arguments to {}, but got {}", function.arguments.size(), function.name, command.argv.size() - 1), command.position); retval = 1; return true; } - auto frame = push_frame(String::formatted("function {}", function.name)); + auto frame = push_frame(DeprecatedString::formatted("function {}", function.name)); size_t index = 0; for (auto& arg : function.arguments) { ++index; @@ -476,7 +476,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval) return true; } -String Shell::format(StringView source, ssize_t& cursor) const +DeprecatedString Shell::format(StringView source, ssize_t& cursor) const { Formatter formatter(source, cursor); auto result = formatter.format(); @@ -485,7 +485,7 @@ String Shell::format(StringView source, ssize_t& cursor) const return result; } -Shell::Frame Shell::push_frame(String name) +Shell::Frame Shell::push_frame(DeprecatedString name) { m_local_frames.append(make<LocalFrame>(name, decltype(LocalFrame::local_variables) {})); dbgln_if(SH_DEBUG, "New frame '{}' at {:p}", name, &m_local_frames.last()); @@ -512,7 +512,7 @@ Shell::Frame::~Frame() (void)frames.take_last(); } -String Shell::resolve_alias(StringView name) const +DeprecatedString Shell::resolve_alias(StringView name) const { return m_aliases.get(name).value_or({}); } @@ -534,7 +534,7 @@ Optional<Shell::RunnablePath> Shell::runnable_path_for(StringView name) return *found; } -Optional<String> Shell::help_path_for(Vector<RunnablePath> visited, Shell::RunnablePath const& runnable_path) +Optional<DeprecatedString> Shell::help_path_for(Vector<RunnablePath> visited, Shell::RunnablePath const& runnable_path) { switch (runnable_path.kind) { case RunnablePath::Kind::Executable: { @@ -734,7 +734,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command) } Vector<char const*> argv; - Vector<String> copy_argv = command.argv; + Vector<DeprecatedString> copy_argv = command.argv; argv.ensure_capacity(command.argv.size() + 1); for (auto& arg : copy_argv) @@ -1012,7 +1012,7 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands) } auto job_result = run_command(command); if (job_result.is_error()) { - raise_error(ShellError::LaunchError, String::formatted("{} while running '{}'", job_result.error(), command.argv.first()), command.position); + raise_error(ShellError::LaunchError, DeprecatedString::formatted("{} while running '{}'", job_result.error(), command.argv.first()), command.position); break; } @@ -1039,7 +1039,7 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands) return spawned_jobs; } -bool Shell::run_file(String const& filename, bool explicitly_invoked) +bool Shell::run_file(DeprecatedString const& filename, bool explicitly_invoked) { TemporaryChange script_change { current_script, filename }; TemporaryChange interactive_change { m_is_interactive, false }; @@ -1047,7 +1047,7 @@ bool Shell::run_file(String const& filename, bool explicitly_invoked) auto file_result = Core::File::open(filename, Core::OpenMode::ReadOnly); if (file_result.is_error()) { - auto error = String::formatted("'{}': {}", escape_token_for_single_quotes(filename), file_result.error()); + auto error = DeprecatedString::formatted("'{}': {}", escape_token_for_single_quotes(filename), file_result.error()); if (explicitly_invoked) raise_error(ShellError::OpenFailure, error); else @@ -1125,14 +1125,14 @@ void Shell::block_on_job(RefPtr<Job> job) block_on_pipeline(command->pipeline); } -String Shell::get_history_path() +DeprecatedString Shell::get_history_path() { if (auto histfile = getenv("HISTFILE")) return { histfile }; - return String::formatted("{}/.history", home); + return DeprecatedString::formatted("{}/.history", home); } -String Shell::escape_token_for_single_quotes(StringView token) +DeprecatedString Shell::escape_token_for_single_quotes(StringView token) { // `foo bar \n '` -> `'foo bar \n '"'"` @@ -1162,7 +1162,7 @@ String Shell::escape_token_for_single_quotes(StringView token) return builder.build(); } -String Shell::escape_token_for_double_quotes(StringView token) +DeprecatedString Shell::escape_token_for_double_quotes(StringView token) { // `foo bar \n $x 'blah "hello` -> `"foo bar \\n $x 'blah \"hello"` @@ -1228,7 +1228,7 @@ Shell::SpecialCharacterEscapeMode Shell::special_character_escape_mode(u32 code_ } } -static String do_escape(Shell::EscapeMode escape_mode, auto& token) +static DeprecatedString do_escape(Shell::EscapeMode escape_mode, auto& token) { StringBuilder builder; for (auto c : token) { @@ -1293,12 +1293,12 @@ static String do_escape(Shell::EscapeMode escape_mode, auto& token) return builder.build(); } -String Shell::escape_token(Utf32View token, EscapeMode escape_mode) +DeprecatedString Shell::escape_token(Utf32View token, EscapeMode escape_mode) { return do_escape(escape_mode, token); } -String Shell::escape_token(StringView token, EscapeMode escape_mode) +DeprecatedString Shell::escape_token(StringView token, EscapeMode escape_mode) { Utf8View view { token }; if (view.validate()) @@ -1306,7 +1306,7 @@ String Shell::escape_token(StringView token, EscapeMode escape_mode) return do_escape(escape_mode, token); } -String Shell::unescape_token(StringView token) +DeprecatedString Shell::unescape_token(StringView token) { StringBuilder builder; @@ -1365,14 +1365,14 @@ void Shell::cache_path() } // TODO: Can we make this rely on Core::File::resolve_executable_from_environment()? - String path = getenv("PATH"); + DeprecatedString path = getenv("PATH"); if (!path.is_empty()) { auto directories = path.split(':'); for (auto const& directory : directories) { Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots); while (programs.has_next()) { auto program = programs.next_path(); - auto program_path = String::formatted("{}/{}", directory, program); + auto program_path = DeprecatedString::formatted("{}/{}", directory, program); auto escaped_name = escape_token(program); if (cached_path.contains_slow(escaped_name)) continue; @@ -1439,7 +1439,7 @@ Vector<Line::CompletionSuggestion> Shell::complete(StringView line) Vector<Line::CompletionSuggestion> Shell::complete_path(StringView base, StringView part, size_t offset, ExecutableOnly executable_only, AST::Node const* command_node, AST::Node const* node, EscapeMode escape_mode) { auto token = offset ? part.substring_view(0, offset) : ""sv; - String path; + DeprecatedString path; ssize_t last_slash = token.length() - 1; while (last_slash >= 0 && token[last_slash] != '/') @@ -1500,7 +1500,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_path(StringView base, StringV auto file = files.next_path(); if (file.starts_with(token)) { struct stat program_status; - auto file_path = String::formatted("{}/{}", path, file); + auto file_path = DeprecatedString::formatted("{}/{}", path, file); int stat_error = stat(file_path.characters(), &program_status); if (!stat_error && (executable_only == ExecutableOnly::No || access(file_path.characters(), X_OK) == 0)) { if (S_ISDIR(program_status.st_mode)) { @@ -1540,7 +1540,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_program_name(StringView name, if (!match) return complete_path(""sv, name, offset, ExecutableOnly::Yes, nullptr, nullptr, escape_mode); - String completion = match->path; + DeprecatedString completion = match->path; auto token_length = escape_token(name, escape_mode).length(); auto invariant_offset = token_length; size_t static_offset = 0; @@ -1594,7 +1594,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_variable(StringView name, siz auto parts = entry.split_view('='); if (parts.is_empty() || parts.first().is_empty()) continue; - String name = parts.first(); + DeprecatedString name = parts.first(); if (suggestions.contains_slow(name)) continue; suggestions.append(move(name)); @@ -1626,7 +1626,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_user(StringView name, size_t return suggestions; while (di.has_next()) { - String name = di.next_path(); + DeprecatedString name = di.next_path(); if (name.starts_with(pattern)) { suggestions.append(name); auto& suggestion = suggestions.last(); @@ -1668,7 +1668,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s if (command_node->would_execute()) return Error::from_string_literal("Refusing to complete nodes that would execute"); - String program_name_storage; + DeprecatedString program_name_storage; if (known_program_name.is_null()) { auto node = command_node->leftmost_trivial_literal(); if (!node) @@ -1684,7 +1684,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s completion_command.argv.append(program_name); completion_command = expand_aliases({ completion_command }).last(); - auto completion_utility_name = String::formatted("_complete_{}", completion_command.argv[0]); + auto completion_utility_name = DeprecatedString::formatted("_complete_{}", completion_command.argv[0]); if (binary_search(cached_path.span(), completion_utility_name, nullptr, RunnablePathComparator {}) != nullptr) completion_command.argv[0] = completion_utility_name; else if (!options.invoke_program_for_autocomplete) @@ -1702,12 +1702,12 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s Shell& shell; AST::Position completion_position; - Vector<Vector<String>> lists; + Vector<Vector<DeprecatedString>> lists; bool fail { false }; void push_list() { lists.empend(); } - Vector<String> pop_list() { return lists.take_last(); } - Vector<String>& list() { return lists.last(); } + Vector<DeprecatedString> pop_list() { return lists.take_last(); } + Vector<DeprecatedString>& list() { return lists.last(); } bool should_include(AST::Node const* node) const { return node->position().end_offset <= completion_position.end_offset; } @@ -1969,7 +1969,7 @@ void Shell::bring_cursor_to_beginning_of_a_line() const // Black with Cyan background. constexpr auto default_mark = "\e[30;46m%\e[0m"; - String eol_mark = getenv("PROMPT_EOL_MARK"); + DeprecatedString eol_mark = getenv("PROMPT_EOL_MARK"); if (eol_mark.is_null()) eol_mark = default_mark; size_t eol_mark_length = Line::Editor::actual_rendered_string_metrics(eol_mark).line_metrics.last().total_length(); @@ -1983,7 +1983,7 @@ void Shell::bring_cursor_to_beginning_of_a_line() const // We write a line's worth of whitespace to the terminal. This way, we ensure that // the prompt ends up on a new line even if there is dangling output on the current line. size_t fill_count = ws.ws_col - eol_mark_length; - auto fill_buffer = String::repeated(' ', fill_count); + auto fill_buffer = DeprecatedString::repeated(' ', fill_count); fwrite(fill_buffer.characters(), 1, fill_count, stderr); putc('\r', stderr); @@ -2387,7 +2387,7 @@ void Shell::possibly_print_error() const } }; int line = -1; - String current_line; + DeprecatedString current_line; i64 line_to_skip_to = max(source_position.position->start_line.line_number, 2ul) - 2; if (!source_position.source_file.is_null()) { diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index 57b2f7ceff..35c309302d 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -10,10 +10,10 @@ #include "Parser.h" #include <AK/Array.h> #include <AK/CircularQueue.h> +#include <AK/DeprecatedString.h> #include <AK/HashMap.h> #include <AK/NonnullOwnPtrVector.h> #include <AK/StackInfo.h> -#include <AK/String.h> #include <AK/StringBuilder.h> #include <AK/StringView.h> #include <AK/Types.h> @@ -88,8 +88,8 @@ public: void setup_signals(); struct SourcePosition { - String source_file; - String literal_source_text; + DeprecatedString source_file; + DeprecatedString literal_source_text; Optional<AST::Position> position; }; @@ -102,7 +102,7 @@ public: }; Kind kind; - String path; + DeprecatedString path; bool operator<(RunnablePath const& other) const { @@ -138,50 +138,50 @@ public: int run_command(StringView, Optional<SourcePosition> = {}); Optional<RunnablePath> runnable_path_for(StringView); - Optional<String> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path); + Optional<DeprecatedString> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path); ErrorOr<RefPtr<Job>> run_command(const AST::Command&); NonnullRefPtrVector<Job> run_commands(Vector<AST::Command>&); - bool run_file(String const&, bool explicitly_invoked = true); + bool run_file(DeprecatedString const&, bool explicitly_invoked = true); bool run_builtin(const AST::Command&, NonnullRefPtrVector<AST::Rewiring> const&, int& retval); bool has_builtin(StringView) const; RefPtr<AST::Node> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&); static bool has_immediate_function(StringView); void block_on_job(RefPtr<Job>); void block_on_pipeline(RefPtr<AST::Pipeline>); - String prompt() const; + DeprecatedString prompt() const; - static String expand_tilde(StringView expression); - static Vector<String> expand_globs(StringView path, StringView base); - static Vector<String> expand_globs(Vector<StringView> path_segments, StringView base); + static DeprecatedString expand_tilde(StringView expression); + static Vector<DeprecatedString> expand_globs(StringView path, StringView base); + static Vector<DeprecatedString> expand_globs(Vector<StringView> path_segments, StringView base); Vector<AST::Command> expand_aliases(Vector<AST::Command>); - String resolve_path(String) const; - String resolve_alias(StringView) const; + DeprecatedString resolve_path(DeprecatedString) const; + DeprecatedString resolve_alias(StringView) const; static bool has_history_event(StringView); RefPtr<AST::Value> get_argument(size_t) const; RefPtr<AST::Value> lookup_local_variable(StringView) const; - String local_variable_or(StringView, String const&) const; - void set_local_variable(String const&, RefPtr<AST::Value>, bool only_in_current_frame = false); + DeprecatedString local_variable_or(StringView, DeprecatedString const&) const; + void set_local_variable(DeprecatedString const&, RefPtr<AST::Value>, bool only_in_current_frame = false); void unset_local_variable(StringView, bool only_in_current_frame = false); - void define_function(String name, Vector<String> argnames, RefPtr<AST::Node> body); + void define_function(DeprecatedString name, Vector<DeprecatedString> argnames, RefPtr<AST::Node> body); bool has_function(StringView); bool invoke_function(const AST::Command&, int& retval); - String format(StringView, ssize_t& cursor) const; + DeprecatedString format(StringView, ssize_t& cursor) const; RefPtr<Line::Editor> editor() const { return m_editor; } struct LocalFrame { - LocalFrame(String name, HashMap<String, RefPtr<AST::Value>> variables) + LocalFrame(DeprecatedString name, HashMap<DeprecatedString, RefPtr<AST::Value>> variables) : name(move(name)) , local_variables(move(variables)) { } - String name; - HashMap<String, RefPtr<AST::Value>> local_variables; + DeprecatedString name; + HashMap<DeprecatedString, RefPtr<AST::Value>> local_variables; }; struct Frame { @@ -200,16 +200,16 @@ public: bool should_destroy_frame { true }; }; - [[nodiscard]] Frame push_frame(String name); + [[nodiscard]] Frame push_frame(DeprecatedString name); void pop_frame(); struct Promise { struct Data { struct Unveil { - String path; - String access; + DeprecatedString path; + DeprecatedString access; }; - String exec_promises; + DeprecatedString exec_promises; Vector<Unveil> unveils; } data; @@ -243,11 +243,11 @@ public: SingleQuotedString, DoubleQuotedString, }; - static String escape_token_for_double_quotes(StringView token); - static String escape_token_for_single_quotes(StringView token); - static String escape_token(StringView token, EscapeMode = EscapeMode::Bareword); - static String escape_token(Utf32View token, EscapeMode = EscapeMode::Bareword); - static String unescape_token(StringView token); + static DeprecatedString escape_token_for_double_quotes(StringView token); + static DeprecatedString escape_token_for_single_quotes(StringView token); + static DeprecatedString escape_token(StringView token, EscapeMode = EscapeMode::Bareword); + static DeprecatedString escape_token(Utf32View token, EscapeMode = EscapeMode::Bareword); + static DeprecatedString unescape_token(StringView token); enum class SpecialCharacterEscapeMode { Untouched, Escaped, @@ -283,7 +283,7 @@ public: Job const* current_job() const { return m_current_job; } void kill_job(Job const*, int sig); - String get_history_path(); + DeprecatedString get_history_path(); void print_path(StringView path); void cache_path(); @@ -296,9 +296,9 @@ public: bool was_interrupted { false }; bool was_resized { false }; - String cwd; - String username; - String home; + DeprecatedString cwd; + DeprecatedString username; + DeprecatedString home; constexpr static auto TTYNameSize = 32; constexpr static auto HostNameSize = 64; @@ -308,12 +308,12 @@ public: uid_t uid; Optional<int> last_return_code; - Vector<String> directory_stack; - CircularQueue<String, 8> cd_history; // FIXME: have a configurable cd history length + Vector<DeprecatedString> directory_stack; + CircularQueue<DeprecatedString, 8> cd_history; // FIXME: have a configurable cd history length HashMap<u64, NonnullRefPtr<Job>> jobs; Vector<RunnablePath, 256> cached_path; - String current_script; + DeprecatedString current_script; enum ShellEventType { ReadLine, @@ -334,7 +334,7 @@ public: LaunchError, }; - void raise_error(ShellError kind, String description, Optional<AST::Position> position = {}) + void raise_error(ShellError kind, DeprecatedString description, Optional<AST::Position> position = {}) { m_error = kind; m_error_description = move(description); @@ -343,7 +343,7 @@ public: } bool has_error(ShellError err) const { return m_error == err; } bool has_any_error() const { return !has_error(ShellError::None); } - String const& error_description() const { return m_error_description; } + DeprecatedString const& error_description() const { return m_error_description; } ShellError take_error() { auto err = m_error; @@ -435,23 +435,23 @@ private: pid_t m_pid { 0 }; struct ShellFunction { - String name; - Vector<String> arguments; + DeprecatedString name; + Vector<DeprecatedString> arguments; RefPtr<AST::Node> body; }; - HashMap<String, ShellFunction> m_functions; + HashMap<DeprecatedString, ShellFunction> m_functions; NonnullOwnPtrVector<LocalFrame> m_local_frames; Promise::List m_active_promises; NonnullRefPtrVector<AST::Redirection> m_global_redirections; - HashMap<String, String> m_aliases; + HashMap<DeprecatedString, DeprecatedString> m_aliases; bool m_is_interactive { true }; bool m_is_subshell { false }; bool m_should_reinstall_signal_handlers { true }; ShellError m_error { ShellError::None }; - String m_error_description; + DeprecatedString m_error_description; Optional<SourcePosition> m_source_position; bool m_should_format_live { false }; @@ -548,7 +548,7 @@ struct Traits<Shell::Shell::RunnablePath> : public GenericTraits<Shell::Shell::R return self.path == other; } - static bool equals(Shell::Shell::RunnablePath const& self, String const& other) + static bool equals(Shell::Shell::RunnablePath const& self, DeprecatedString const& other) { return self.path == other; } diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 57dc492b22..6214ea8f6d 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -104,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } if (should_escape) { - String escaped_string; + DeprecatedString escaped_string; Optional<char> trivia {}; bool starting_trivia_already_provided = false; auto escape_mode = Shell::Shell::EscapeMode::Bareword; @@ -156,7 +156,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) StringView command_to_run = {}; StringView file_to_read_from = {}; - Vector<String> script_args; + Vector<DeprecatedString> script_args; bool skip_rc_files = false; char const* format = nullptr; bool should_format_live = false; @@ -213,7 +213,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!skip_rc_files) { auto run_rc_file = [&](auto& name) { - String file_path = name; + DeprecatedString file_path = name; if (file_path.starts_with('~')) file_path = shell->expand_tilde(file_path); if (Core::File::exists(file_path)) { |