Shell: Stop lying about string types

This commit is contained in:
Hendiadyoin1 2023-06-11 19:47:20 +02:00 committed by Jelle Raaijmakers
parent eeb15fc10b
commit 3d83d70cac
Notes: sideshowbarker 2024-07-17 03:03:37 +09:00
4 changed files with 6 additions and 6 deletions

View file

@ -3796,7 +3796,7 @@ ErrorOr<Vector<String>> GlobValue::resolve_as_list(RefPtr<Shell> shell)
Vector<String> strings; Vector<String> strings;
TRY(strings.try_ensure_capacity(results.size())); TRY(strings.try_ensure_capacity(results.size()));
for (auto& entry : results) { for (auto& entry : results) {
TRY(strings.try_append(TRY(String::from_utf8(entry)))); TRY(strings.try_append(TRY(String::from_deprecated_string(entry))));
} }
return resolve_slices(shell, move(strings), m_slices); return resolve_slices(shell, move(strings), m_slices);
@ -3927,7 +3927,7 @@ ErrorOr<Vector<String>> TildeValue::resolve_as_list(RefPtr<Shell> shell)
if (!shell) if (!shell)
return { resolve_slices(shell, Vector { TRY(builder.to_string()) }, m_slices) }; return { resolve_slices(shell, Vector { TRY(builder.to_string()) }, m_slices) };
return { resolve_slices(shell, Vector { TRY(String::from_utf8(shell->expand_tilde(builder.to_deprecated_string()))) }, m_slices) }; return { resolve_slices(shell, Vector { TRY(String::from_deprecated_string(shell->expand_tilde(builder.to_deprecated_string()))) }, m_slices) };
} }
ErrorOr<NonnullRefPtr<Rewiring>> CloseRedirection::apply() const ErrorOr<NonnullRefPtr<Rewiring>> CloseRedirection::apply() const

View file

@ -598,7 +598,7 @@ void Formatter::visit(const AST::MatchExpr* node)
if (!first) if (!first)
current_builder().append(" | "sv); current_builder().append(" | "sv);
first = false; first = false;
auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_utf8(option.pattern_value).release_value_but_fixme_should_propagate_errors()); auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_deprecated_string(option.pattern_value).release_value_but_fixme_should_propagate_errors());
node->visit(*this); node->visit(*this);
} }
}); });

View file

@ -232,7 +232,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpressi
TRY(replacement->resolve_as_list(this))[0], TRY(replacement->resolve_as_list(this))[0],
PosixFlags::Global | PosixFlags::Multiline | PosixFlags::Unicode); PosixFlags::Global | PosixFlags::Multiline | PosixFlags::Unicode);
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_utf8(result)), AST::StringLiteral::EnclosureType::None); return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_deprecated_string(result)), AST::StringLiteral::EnclosureType::None);
} }
ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments) ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)

View file

@ -1023,12 +1023,12 @@ AST::MatchEntry Parser::parse_match_entry()
for (auto& regex : regexps) { for (auto& regex : regexps) {
if (names.is_empty()) { if (names.is_empty()) {
for (auto& name : regex.parser_result.capture_groups) for (auto& name : regex.parser_result.capture_groups)
names.append(String::from_utf8(name).release_value_but_fixme_should_propagate_errors()); names.append(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors());
} else { } else {
size_t index = 0; size_t index = 0;
for (auto& name : regex.parser_result.capture_groups) { for (auto& name : regex.parser_result.capture_groups) {
if (names.size() <= index) { if (names.size() <= index) {
names.append(String::from_utf8(name).release_value_but_fixme_should_propagate_errors()); names.append(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors());
continue; continue;
} }