mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:17:35 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -109,7 +109,7 @@ namespace Shell::AST {
|
|||
template<typename... Args>
|
||||
static inline void print_indented(int indent, CheckedFormatString<Args...> format, Args&&... args)
|
||||
{
|
||||
auto str = DeprecatedString::formatted(format.view(), forward<Args>(args)...);
|
||||
auto str = ByteString::formatted(format.view(), forward<Args>(args)...);
|
||||
dbgln("{: >{}}", str, str.length() + indent * 2);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value,
|
|||
for (auto& value : index_values) {
|
||||
auto maybe_index = value.bytes_as_string_view().to_int();
|
||||
if (!maybe_index.has_value()) {
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, ByteString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
|
||||
return move(input_value);
|
||||
}
|
||||
++i;
|
||||
|
@ -190,7 +190,7 @@ static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value,
|
|||
index += input_value.bytes_as_string_view().length();
|
||||
|
||||
if (index < 0 || (size_t)index >= input_value.bytes_as_string_view().length()) {
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.bytes_as_string_view().length()), slice->position());
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, ByteString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.bytes_as_string_view().length()), slice->position());
|
||||
return move(input_value);
|
||||
}
|
||||
indices.unchecked_append(index);
|
||||
|
@ -229,7 +229,7 @@ static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String
|
|||
for (auto& value : index_values) {
|
||||
auto maybe_index = value.bytes_as_string_view().to_int();
|
||||
if (!maybe_index.has_value()) {
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, ByteString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
|
||||
return move(values);
|
||||
}
|
||||
++i;
|
||||
|
@ -240,7 +240,7 @@ static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String
|
|||
index += values.size();
|
||||
|
||||
if (index < 0 || (size_t)index >= values.size()) {
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice->position());
|
||||
shell->raise_error(Shell::ShellError::InvalidSliceContentsError, ByteString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice->position());
|
||||
return move(values);
|
||||
}
|
||||
indices.unchecked_append(index);
|
||||
|
@ -648,7 +648,7 @@ ErrorOr<void> BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell&
|
|||
auto name = shell.help_path_for({}, *runnable);
|
||||
if (name.has_value()) {
|
||||
auto url = URL::create_with_help_scheme(name.release_value(), shell.hostname);
|
||||
style = bold.unified_with(Line::Style::Hyperlink(url.to_deprecated_string()));
|
||||
style = bold.unified_with(Line::Style::Hyperlink(url.to_byte_string()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -681,8 +681,8 @@ ErrorOr<void> BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell&
|
|||
if (FileSystem::exists(m_text)) {
|
||||
auto realpath = shell.resolve_path(m_text.bytes_as_string_view());
|
||||
auto url = URL::create_with_file_scheme(realpath);
|
||||
url.set_host(TRY(String::from_deprecated_string(shell.hostname)));
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
url.set_host(TRY(String::from_byte_string(shell.hostname)));
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_byte_string()) });
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -1132,11 +1132,11 @@ ErrorOr<void> FunctionDeclaration::dump(int level) const
|
|||
|
||||
ErrorOr<RefPtr<Value>> FunctionDeclaration::run(RefPtr<Shell> shell)
|
||||
{
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
for (auto& arg : m_arguments)
|
||||
args.append(arg.name.to_deprecated_string());
|
||||
args.append(arg.name.to_byte_string());
|
||||
|
||||
shell->define_function(m_name.name.to_deprecated_string(), move(args), m_block);
|
||||
shell->define_function(m_name.name.to_byte_string(), move(args), m_block);
|
||||
|
||||
return make_ref_counted<ListValue>({});
|
||||
}
|
||||
|
@ -1182,7 +1182,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> FunctionDeclaration::complete_for_ed
|
|||
Vector<Line::CompletionSuggestion> results;
|
||||
for (auto& arg : m_arguments) {
|
||||
if (arg.name.starts_with_bytes(name))
|
||||
results.append(arg.name.to_deprecated_string());
|
||||
results.append(arg.name.to_byte_string());
|
||||
}
|
||||
|
||||
results.extend(TRY(matching_node->complete_for_editor(shell, offset, hit_test_result)));
|
||||
|
@ -1279,7 +1279,7 @@ ErrorOr<RefPtr<Value>> ForLoop::run(RefPtr<Shell> shell)
|
|||
RefPtr<Value> block_value;
|
||||
|
||||
{
|
||||
auto frame = shell->push_frame(DeprecatedString::formatted("for ({})", this));
|
||||
auto frame = shell->push_frame(ByteString::formatted("for ({})", this));
|
||||
shell->set_local_variable(variable_name.bytes_as_string_view(), value, true);
|
||||
|
||||
if (index_name.has_value())
|
||||
|
@ -1469,7 +1469,7 @@ ErrorOr<RefPtr<Value>> Heredoc::run(RefPtr<Shell> shell)
|
|||
if (rc != 0) {
|
||||
// pipe() failed for {}
|
||||
if (shell)
|
||||
shell->raise_error(Shell::ShellError::PipeFailure, DeprecatedString::formatted("heredoc: {}", strerror(errno)), position());
|
||||
shell->raise_error(Shell::ShellError::PipeFailure, ByteString::formatted("heredoc: {}", strerror(errno)), position());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1605,7 +1605,7 @@ ErrorOr<RefPtr<Value>> HistoryEvent::run(RefPtr<Shell> shell)
|
|||
return it_end;
|
||||
};
|
||||
// First, resolve the event itself.
|
||||
DeprecatedString resolved_history;
|
||||
ByteString resolved_history;
|
||||
switch (m_selector.event.kind) {
|
||||
case HistorySelector::EventKind::IndexFromStart:
|
||||
if (m_selector.event.index >= history.size()) {
|
||||
|
@ -2337,9 +2337,9 @@ ErrorOr<RefPtr<Value>> MatchExpr::run(RefPtr<Shell> shell)
|
|||
}
|
||||
};
|
||||
|
||||
auto frame = shell->push_frame(DeprecatedString::formatted("match ({})", this));
|
||||
auto frame = shell->push_frame(ByteString::formatted("match ({})", this));
|
||||
if (!m_expr_name.is_empty())
|
||||
shell->set_local_variable(m_expr_name.to_deprecated_string(), value, true);
|
||||
shell->set_local_variable(m_expr_name.to_byte_string(), value, true);
|
||||
|
||||
for (auto& entry : m_entries) {
|
||||
auto result = TRY(entry.options.visit([&](auto& options) -> ErrorOr<Variant<IterationDecision, RefPtr<Value>>> {
|
||||
|
@ -2351,7 +2351,7 @@ ErrorOr<RefPtr<Value>> MatchExpr::run(RefPtr<Shell> shell)
|
|||
size_t i = 0;
|
||||
for (auto& name : entry.match_names.value()) {
|
||||
if (spans.size() > i)
|
||||
shell->set_local_variable(name.to_deprecated_string(), make_ref_counted<AST::StringValue>(spans[i]), true);
|
||||
shell->set_local_variable(name.to_byte_string(), make_ref_counted<AST::StringValue>(spans[i]), true);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
@ -2625,9 +2625,9 @@ ErrorOr<void> PathRedirectionNode::highlight_in_editor(Line::Editor& editor, She
|
|||
auto& path = path_text[0];
|
||||
if (!path.starts_with('/'))
|
||||
path = TRY(String::formatted("{}/{}", shell.cwd, path));
|
||||
auto url = URL::create_with_file_scheme(path.to_deprecated_string());
|
||||
url.set_host(TRY(String::from_deprecated_string(shell.hostname)));
|
||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
auto url = URL::create_with_file_scheme(path.to_byte_string());
|
||||
url.set_host(TRY(String::from_byte_string(shell.hostname)));
|
||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_byte_string()) });
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -2713,7 +2713,7 @@ ErrorOr<RefPtr<Value>> Range::run(RefPtr<Shell> shell)
|
|||
}
|
||||
} else {
|
||||
yield_start_end:;
|
||||
shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Cannot interpolate between '{}' and '{}'!", start_str, end_str), position);
|
||||
shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, ByteString::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)));
|
||||
|
@ -3215,13 +3215,13 @@ ErrorOr<void> Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& sh
|
|||
path_builder.append(tilde_value);
|
||||
path_builder.append('/');
|
||||
path_builder.append(bareword_value);
|
||||
auto path = path_builder.to_deprecated_string();
|
||||
auto path = path_builder.to_byte_string();
|
||||
|
||||
if (FileSystem::exists(path)) {
|
||||
auto realpath = shell.resolve_path(path);
|
||||
auto url = URL::create_with_file_scheme(realpath);
|
||||
url.set_host(TRY(String::from_deprecated_string(shell.hostname)));
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
url.set_host(TRY(String::from_byte_string(shell.hostname)));
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_byte_string()) });
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -3398,7 +3398,7 @@ ErrorOr<void> SyntaxError::dump(int level) const
|
|||
|
||||
ErrorOr<RefPtr<Value>> SyntaxError::run(RefPtr<Shell> shell)
|
||||
{
|
||||
shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, m_syntax_error_text.to_deprecated_string(), position());
|
||||
shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, m_syntax_error_text.to_byte_string(), position());
|
||||
return make_ref_counted<StringValue>(String {});
|
||||
}
|
||||
|
||||
|
@ -3593,7 +3593,7 @@ ErrorOr<RefPtr<Value>> VariableDeclarations::run(RefPtr<Shell> shell)
|
|||
break;
|
||||
value = TRY(value->resolve_without_cast(shell));
|
||||
|
||||
shell->set_local_variable(name.to_deprecated_string(), value.release_nonnull());
|
||||
shell->set_local_variable(name.to_byte_string(), value.release_nonnull());
|
||||
}
|
||||
|
||||
return make_ref_counted<ListValue>({});
|
||||
|
@ -3802,7 +3802,7 @@ ErrorOr<Vector<String>> GlobValue::resolve_as_list(RefPtr<Shell> shell)
|
|||
Vector<String> strings;
|
||||
TRY(strings.try_ensure_capacity(results.size()));
|
||||
for (auto& entry : results) {
|
||||
TRY(strings.try_append(TRY(String::from_deprecated_string(entry))));
|
||||
TRY(strings.try_append(TRY(String::from_byte_string(entry))));
|
||||
}
|
||||
|
||||
return resolve_slices(shell, move(strings), m_slices);
|
||||
|
@ -3820,7 +3820,7 @@ ErrorOr<String> SimpleVariableValue::resolve_as_string(RefPtr<Shell> shell)
|
|||
if (auto value = TRY(resolve_without_cast(shell)); value != this)
|
||||
return resolve_slices(shell, TRY(value->resolve_as_string(shell)), m_slices);
|
||||
|
||||
auto name = m_name.to_deprecated_string();
|
||||
auto name = m_name.to_byte_string();
|
||||
char const* env_value = getenv(name.characters());
|
||||
if (!env_value)
|
||||
env_value = "";
|
||||
|
@ -3836,7 +3836,7 @@ ErrorOr<Vector<String>> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell
|
|||
if (auto value = TRY(resolve_without_cast(shell)); value != this)
|
||||
return value->resolve_as_list(shell);
|
||||
|
||||
auto name = m_name.to_deprecated_string();
|
||||
auto name = m_name.to_byte_string();
|
||||
char* env_value = getenv(name.characters());
|
||||
if (env_value == nullptr)
|
||||
return { resolve_slices(shell, Vector { String {} }, m_slices) };
|
||||
|
@ -3933,7 +3933,7 @@ ErrorOr<Vector<String>> TildeValue::resolve_as_list(RefPtr<Shell> shell)
|
|||
if (!shell)
|
||||
return { resolve_slices(shell, Vector { TRY(builder.to_string()) }, m_slices) };
|
||||
|
||||
return { resolve_slices(shell, Vector { TRY(String::from_deprecated_string(shell->expand_tilde(builder.to_deprecated_string()))) }, m_slices) };
|
||||
return { resolve_slices(shell, Vector { TRY(String::from_byte_string(shell->expand_tilde(builder.to_byte_string()))) }, m_slices) };
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Rewiring>> CloseRedirection::apply() const
|
||||
|
@ -3956,7 +3956,7 @@ ErrorOr<NonnullRefPtr<Rewiring>> PathRedirection::apply() const
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) Rewiring(fd, my_fd, Rewiring::Close::Old));
|
||||
};
|
||||
|
||||
auto path_string = path.to_deprecated_string();
|
||||
auto path_string = path.to_byte_string();
|
||||
switch (direction) {
|
||||
case AST::PathRedirection::WriteAppend:
|
||||
return check_fd_and_return(open(path_string.characters(), O_WRONLY | O_CREAT | O_APPEND, 0666), path);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "Formatter.h"
|
||||
#include "PosixParser.h"
|
||||
#include "Shell.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/Statistics.h>
|
||||
|
@ -98,13 +98,13 @@ ErrorOr<int> Shell::builtin_where(Main::Arguments arguments)
|
|||
if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::PrintUsage))
|
||||
return 1;
|
||||
|
||||
auto const look_up_alias = [do_only_path_search, &m_aliases = this->m_aliases](StringView alias) -> Optional<DeprecatedString> {
|
||||
auto const look_up_alias = [do_only_path_search, &m_aliases = this->m_aliases](StringView alias) -> Optional<ByteString> {
|
||||
if (do_only_path_search)
|
||||
return {};
|
||||
return m_aliases.get(alias);
|
||||
};
|
||||
|
||||
auto const look_up_builtin = [do_only_path_search](StringView builtin) -> Optional<DeprecatedString> {
|
||||
auto const look_up_builtin = [do_only_path_search](StringView builtin) -> Optional<ByteString> {
|
||||
if (do_only_path_search)
|
||||
return {};
|
||||
for (auto const& _builtin : builtin_names) {
|
||||
|
@ -162,7 +162,7 @@ ErrorOr<int> Shell::builtin_reset(Main::Arguments)
|
|||
|
||||
ErrorOr<int> Shell::builtin_alias(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> aliases;
|
||||
Vector<ByteString> aliases;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(aliases, "List of name[=values]'s", "name[=value]", Core::ArgsParser::Required::No);
|
||||
|
@ -198,7 +198,7 @@ ErrorOr<int> Shell::builtin_alias(Main::Arguments arguments)
|
|||
ErrorOr<int> Shell::builtin_unalias(Main::Arguments arguments)
|
||||
{
|
||||
bool remove_all { false };
|
||||
Vector<DeprecatedString> aliases;
|
||||
Vector<ByteString> aliases;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.set_general_help("Remove alias from the list of aliases");
|
||||
|
@ -371,7 +371,7 @@ ErrorOr<String> Shell::serialize_function_definition(ShellFunction const& fn) co
|
|||
|
||||
ErrorOr<int> Shell::builtin_type(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> commands;
|
||||
Vector<ByteString> commands;
|
||||
bool dont_show_function_source = false;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
|
@ -434,7 +434,7 @@ ErrorOr<int> Shell::builtin_cd(Main::Arguments arguments)
|
|||
if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::PrintUsage))
|
||||
return 1;
|
||||
|
||||
DeprecatedString new_path;
|
||||
ByteString new_path;
|
||||
|
||||
if (arg_path.is_empty()) {
|
||||
new_path = home;
|
||||
|
@ -454,7 +454,7 @@ ErrorOr<int> Shell::builtin_cd(Main::Arguments arguments)
|
|||
warnln("Invalid path '{}'", new_path);
|
||||
return 1;
|
||||
}
|
||||
auto real_path = real_path_or_error.release_value().to_deprecated_string();
|
||||
auto real_path = real_path_or_error.release_value().to_byte_string();
|
||||
|
||||
if (cd_history.is_empty() || cd_history.last() != real_path)
|
||||
cd_history.enqueue(real_path);
|
||||
|
@ -520,7 +520,7 @@ ErrorOr<int> Shell::builtin_dirs(Main::Arguments arguments)
|
|||
bool number_when_printing = false;
|
||||
char separator = ' ';
|
||||
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_option(clear, "Clear the directory stack", "clear", 'c');
|
||||
|
@ -627,7 +627,7 @@ ErrorOr<int> Shell::builtin_exit(Main::Arguments arguments)
|
|||
|
||||
ErrorOr<int> Shell::builtin_export(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> vars;
|
||||
Vector<ByteString> vars;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(vars, "List of variable[=value]'s", "values", Core::ArgsParser::Required::No);
|
||||
|
@ -654,7 +654,7 @@ ErrorOr<int> Shell::builtin_export(Main::Arguments arguments)
|
|||
auto values = TRY(const_cast<AST::Value&>(*value).resolve_as_list(*this));
|
||||
StringBuilder builder;
|
||||
builder.join(' ', values);
|
||||
parts.append(builder.to_deprecated_string());
|
||||
parts.append(builder.to_byte_string());
|
||||
} else {
|
||||
// Ignore the export.
|
||||
continue;
|
||||
|
@ -677,7 +677,7 @@ ErrorOr<int> Shell::builtin_export(Main::Arguments arguments)
|
|||
|
||||
ErrorOr<int> Shell::builtin_glob(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> globs;
|
||||
Vector<ByteString> globs;
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(globs, "Globs to resolve", "glob");
|
||||
|
||||
|
@ -907,8 +907,8 @@ ErrorOr<int> Shell::builtin_pushd(Main::Arguments arguments)
|
|||
return 1;
|
||||
}
|
||||
|
||||
DeprecatedString dir1 = directory_stack.take_first();
|
||||
DeprecatedString dir2 = directory_stack.take_first();
|
||||
ByteString dir1 = directory_stack.take_first();
|
||||
ByteString dir2 = directory_stack.take_first();
|
||||
directory_stack.insert(0, dir2);
|
||||
directory_stack.insert(1, dir1);
|
||||
|
||||
|
@ -949,7 +949,7 @@ ErrorOr<int> Shell::builtin_pushd(Main::Arguments arguments)
|
|||
}
|
||||
}
|
||||
|
||||
auto real_path = LexicalPath::canonicalized_path(path_builder.to_deprecated_string());
|
||||
auto real_path = LexicalPath::canonicalized_path(path_builder.to_byte_string());
|
||||
|
||||
struct stat st;
|
||||
int rc = stat(real_path.characters(), &st);
|
||||
|
@ -1134,7 +1134,7 @@ ErrorOr<int> Shell::builtin_time(Main::Arguments arguments)
|
|||
|
||||
warnln("Timing report: {} ms", iteration_times.sum());
|
||||
warnln("==============");
|
||||
warnln("Command: {}", DeprecatedString::join(' ', arguments.strings));
|
||||
warnln("Command: {}", ByteString::join(' ', arguments.strings));
|
||||
warnln("Average time: {:.2} ms (median: {}, stddev: {:.2}, min: {}, max:{})",
|
||||
iteration_times.average(), iteration_times.median(),
|
||||
iteration_times.standard_deviation(),
|
||||
|
@ -1283,7 +1283,7 @@ ErrorOr<int> Shell::builtin_wait(Main::Arguments arguments)
|
|||
|
||||
ErrorOr<int> Shell::builtin_unset(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> vars;
|
||||
Vector<ByteString> vars;
|
||||
bool unset_only_variables = false; // POSIX only.
|
||||
|
||||
Core::ArgsParser parser;
|
||||
|
@ -1321,7 +1321,7 @@ ErrorOr<int> Shell::builtin_set(Main::Arguments arguments)
|
|||
for (auto& frame : m_local_frames) {
|
||||
for (auto& var : frame->local_variables) {
|
||||
builder.join(" "sv, TRY(var.value->resolve_as_list(*this)));
|
||||
vars.set(TRY(String::from_deprecated_string(var.key)), TRY(builder.to_string()));
|
||||
vars.set(TRY(String::from_byte_string(var.key)), TRY(builder.to_string()));
|
||||
builder.clear();
|
||||
}
|
||||
}
|
||||
|
@ -1518,11 +1518,11 @@ ErrorOr<int> Shell::builtin_argsparser_parse(Main::Arguments arguments)
|
|||
|
||||
Vector<StringView> descriptors;
|
||||
Variant<Core::ArgsParser::Option, Core::ArgsParser::Arg, Empty> current;
|
||||
DeprecatedString help_string_storage;
|
||||
DeprecatedString long_name_storage;
|
||||
DeprecatedString value_name_storage;
|
||||
DeprecatedString name_storage;
|
||||
DeprecatedString current_variable;
|
||||
ByteString help_string_storage;
|
||||
ByteString long_name_storage;
|
||||
ByteString value_name_storage;
|
||||
ByteString name_storage;
|
||||
ByteString current_variable;
|
||||
// if max > 1 or min < 1, or explicit `--list`.
|
||||
bool treat_arg_as_list = false;
|
||||
enum class Type {
|
||||
|
@ -1556,7 +1556,7 @@ ErrorOr<int> Shell::builtin_argsparser_parse(Main::Arguments arguments)
|
|||
warnln("Invalid value for type u32|size: {}", value);
|
||||
return OptionalNone {};
|
||||
case Type::Double: {
|
||||
DeprecatedString string = value;
|
||||
ByteString string = value;
|
||||
char* endptr = nullptr;
|
||||
auto number = strtod(string.characters(), &endptr);
|
||||
if (endptr != string.characters() + string.length()) {
|
||||
|
@ -1938,7 +1938,7 @@ ErrorOr<int> Shell::builtin_argsparser_parse(Main::Arguments arguments)
|
|||
ErrorOr<int> Shell::builtin_read(Main::Arguments arguments)
|
||||
{
|
||||
bool no_escape = false;
|
||||
Vector<DeprecatedString> variables;
|
||||
Vector<ByteString> variables;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_option(no_escape, "Do not interpret backslash escapes", "no-escape", 'r');
|
||||
|
@ -2023,7 +2023,7 @@ ErrorOr<int> Shell::builtin_read(Main::Arguments arguments)
|
|||
|
||||
ErrorOr<int> Shell::builtin_run_with_env(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> environment_variables;
|
||||
Vector<ByteString> environment_variables;
|
||||
Vector<StringView> command_and_arguments;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
|
@ -2046,7 +2046,7 @@ ErrorOr<int> Shell::builtin_run_with_env(Main::Arguments arguments)
|
|||
|
||||
auto commands = TRY(expand_aliases({ move(command) }));
|
||||
|
||||
HashMap<DeprecatedString, Optional<DeprecatedString>> old_environment_entries;
|
||||
HashMap<ByteString, Optional<ByteString>> old_environment_entries;
|
||||
for (auto& variable : environment_variables) {
|
||||
auto parts = variable.split_limit('=', 2, SplitBehavior::KeepEmpty);
|
||||
if (parts.size() != 2) {
|
||||
|
@ -2054,10 +2054,10 @@ ErrorOr<int> Shell::builtin_run_with_env(Main::Arguments arguments)
|
|||
return 1;
|
||||
}
|
||||
|
||||
DeprecatedString name = parts[0];
|
||||
old_environment_entries.set(name, getenv(name.characters()) ?: Optional<DeprecatedString> {});
|
||||
ByteString name = parts[0];
|
||||
old_environment_entries.set(name, getenv(name.characters()) ?: Optional<ByteString> {});
|
||||
|
||||
DeprecatedString value = parts[1];
|
||||
ByteString value = parts[1];
|
||||
setenv(name.characters(), value.characters(), 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
namespace Shell {
|
||||
|
||||
DeprecatedString Formatter::format()
|
||||
ByteString Formatter::format()
|
||||
{
|
||||
auto node = m_root_node ?: (m_parse_as_posix ? Posix::Parser(m_source).parse() : Parser(m_source).parse());
|
||||
if (m_cursor >= 0)
|
||||
m_output_cursor = m_cursor;
|
||||
|
||||
if (!node)
|
||||
return DeprecatedString();
|
||||
return ByteString();
|
||||
|
||||
if (node->is_syntax_error())
|
||||
return m_source;
|
||||
|
@ -45,7 +45,7 @@ DeprecatedString Formatter::format()
|
|||
if (!string.ends_with(' '))
|
||||
current_builder().append(m_trivia);
|
||||
|
||||
return current_builder().to_deprecated_string();
|
||||
return current_builder().to_byte_string();
|
||||
}
|
||||
|
||||
void Formatter::with_added_indent(int indent, Function<void()> callback)
|
||||
|
@ -67,11 +67,11 @@ void Formatter::in_new_block(Function<void()> callback)
|
|||
current_builder().append('}');
|
||||
}
|
||||
|
||||
DeprecatedString Formatter::in_new_builder(Function<void()> callback, StringBuilder new_builder)
|
||||
ByteString Formatter::in_new_builder(Function<void()> callback, StringBuilder new_builder)
|
||||
{
|
||||
m_builders.append(move(new_builder));
|
||||
callback();
|
||||
return m_builders.take_last().to_deprecated_string();
|
||||
return m_builders.take_last().to_byte_string();
|
||||
}
|
||||
|
||||
void Formatter::test_and_update_output_cursor(const AST::Node* node)
|
||||
|
@ -598,7 +598,7 @@ void Formatter::visit(const AST::MatchExpr* node)
|
|||
if (!first)
|
||||
current_builder().append(" | "sv);
|
||||
first = false;
|
||||
auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_deprecated_string(option.pattern_value).release_value_but_fixme_should_propagate_errors());
|
||||
auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_byte_string(option.pattern_value).release_value_but_fixme_should_propagate_errors());
|
||||
node->visit(*this);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "AST.h"
|
||||
#include "NodeVisitor.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
DeprecatedString format();
|
||||
ByteString format();
|
||||
size_t cursor() const { return m_output_cursor; }
|
||||
|
||||
private:
|
||||
|
@ -99,7 +99,7 @@ private:
|
|||
|
||||
ALWAYS_INLINE void with_added_indent(int indent, Function<void()>);
|
||||
ALWAYS_INLINE void in_new_block(Function<void()>);
|
||||
ALWAYS_INLINE DeprecatedString in_new_builder(Function<void()>, StringBuilder new_builder = StringBuilder {});
|
||||
ALWAYS_INLINE ByteString in_new_builder(Function<void()>, StringBuilder new_builder = StringBuilder {});
|
||||
|
||||
StringBuilder& current_builder() { return m_builders.last(); }
|
||||
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
const AST::Node* m_last_visited_node { nullptr };
|
||||
|
||||
StringView m_trivia;
|
||||
Vector<DeprecatedString> m_heredocs_to_append_after_sequence;
|
||||
Vector<ByteString> m_heredocs_to_append_after_sequence;
|
||||
|
||||
bool m_parse_as_posix { false };
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
{
|
||||
auto name = across ? "length_across" : "length";
|
||||
if (arguments.size() < 1 || arguments.size() > 2) {
|
||||
raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected one or two arguments to `{}'", name), invoking_node.position());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Expected one or two arguments to `{}'", name), invoking_node.position());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
|
||||
auto& mode_arg = arguments.first();
|
||||
if (!mode_arg->is_bareword()) {
|
||||
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());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Expected a bareword (either 'string' or 'list') in the two-argument form of the `{}' immediate", name), mode_arg->position());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
} else if (mode_name == "infer") {
|
||||
mode = Infer;
|
||||
} else {
|
||||
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());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Expected either 'string' or 'list' (and not {}) in the two-argument form of the `{}' immediate", mode_name, name), mode_arg->position());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
|
||||
if (is_inferred) {
|
||||
raise_error(ShellError::EvaluatedSyntaxError,
|
||||
DeprecatedString::formatted("Could not infer expression type, please explicitly use `{0} string' or `{0} list'", name),
|
||||
ByteString::formatted("Could not infer expression type, please explicitly use `{0} string' or `{0} list'", name),
|
||||
invoking_node.position());
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
raise_error(ShellError::EvaluatedSyntaxError,
|
||||
source.is_empty()
|
||||
? "Invalid application of `length' to a list"
|
||||
: 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"),
|
||||
: ByteString::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;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
|
|||
|
||||
auto source = formatter.format();
|
||||
raise_error(ShellError::EvaluatedSyntaxError,
|
||||
DeprecatedString::formatted("Invalid application of `length_across' to a non-list\nperhaps you meant `{1}length {0}{2}'?", source, "\x1b[32m", "\x1b[0m"),
|
||||
ByteString::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;
|
||||
}
|
||||
|
@ -226,13 +226,13 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpressi
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Regex<PosixExtendedParser> re { TRY(pattern->resolve_as_list(this)).first().to_deprecated_string() };
|
||||
Regex<PosixExtendedParser> re { TRY(pattern->resolve_as_list(this)).first().to_byte_string() };
|
||||
auto result = re.replace(
|
||||
TRY(value->resolve_as_list(this))[0],
|
||||
TRY(replacement->resolve_as_list(this))[0],
|
||||
PosixFlags::Global | PosixFlags::Multiline | PosixFlags::Unicode);
|
||||
|
||||
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_deprecated_string(result)), AST::StringLiteral::EnclosureType::None);
|
||||
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_byte_string(result)), AST::StringLiteral::EnclosureType::None);
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
|
||||
|
@ -484,7 +484,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_default(AST::ImmediateExpress
|
|||
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
|
||||
|
||||
auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_without_cast(*this));
|
||||
set_local_variable(name.to_deprecated_string(), value);
|
||||
set_local_variable(name.to_byte_string(), value);
|
||||
|
||||
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_defined_default(AST::Immediat
|
|||
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
|
||||
|
||||
auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_without_cast(*this));
|
||||
set_local_variable(name.to_deprecated_string(), value);
|
||||
set_local_variable(name.to_byte_string(), value);
|
||||
|
||||
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_math(AST::ImmediateExpression& invok
|
|||
case U'\r':
|
||||
break;
|
||||
default:
|
||||
raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Unexpected character '{:c}' in math expression", code_point), arguments.first()->position());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Unexpected character '{:c}' in math expression", code_point), arguments.first()->position());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1268,7 +1268,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_math(AST::ImmediateExpression& invok
|
|||
}
|
||||
|
||||
if (resolution_attempts_remaining == 0)
|
||||
raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Too many indirections when resolving variable '{}'", name), arguments.first()->position());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Too many indirections when resolving variable '{}'", name), arguments.first()->position());
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
@ -1296,7 +1296,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_math(AST::ImmediateExpression& invok
|
|||
}));
|
||||
}
|
||||
|
||||
set_local_variable(name->to_deprecated_string(), make_ref_counted<AST::StringValue>(TRY(String::number(rhs))));
|
||||
set_local_variable(name->to_byte_string(), make_ref_counted<AST::StringValue>(TRY(String::number(rhs))));
|
||||
return rhs;
|
||||
}
|
||||
|
||||
|
@ -1372,7 +1372,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_math(AST::ImmediateExpression& invok
|
|||
return TRY(interpret(node->false_value));
|
||||
},
|
||||
[&](NonnullOwnPtr<Arithmetic::ErrorNode> const& node) -> ErrorOr<i64> {
|
||||
raise_error(ShellError::EvaluatedSyntaxError, node->error.to_deprecated_string(), arguments.first()->position());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, node->error.to_byte_string(), arguments.first()->position());
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
@ -1391,7 +1391,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::run_immediate_function(StringView str, AST::Im
|
|||
ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS()
|
||||
|
||||
#undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION
|
||||
raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Unknown immediate function {}", str), invoking_node.position());
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::formatted("Unknown immediate function {}", str), invoking_node.position());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ bool Job::print_status(PrintStatusMode mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
Job::Job(pid_t pid, unsigned pgid, DeprecatedString cmd, u64 job_id, AST::Command&& command)
|
||||
Job::Job(pid_t pid, unsigned pgid, ByteString cmd, u64 job_id, AST::Command&& command)
|
||||
: m_pgid(pgid)
|
||||
, m_pid(pid)
|
||||
, m_job_id(job_id)
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "Execution.h"
|
||||
#include "Forward.h"
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
|
@ -23,7 +23,7 @@ struct LocalFrame;
|
|||
|
||||
class Job : public RefCounted<Job> {
|
||||
public:
|
||||
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))); }
|
||||
static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, ByteString 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; }
|
||||
DeprecatedString const& cmd() const { return m_cmd; }
|
||||
ByteString 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, DeprecatedString cmd, u64 job_id, AST::Command&& command);
|
||||
Job(pid_t pid, unsigned pgid, ByteString cmd, u64 job_id, AST::Command&& command);
|
||||
|
||||
pid_t m_pgid { 0 };
|
||||
pid_t m_pid { 0 };
|
||||
u64 m_job_id { 0 };
|
||||
DeprecatedString m_cmd;
|
||||
ByteString m_cmd;
|
||||
bool m_exited { false };
|
||||
bool m_running_in_background { false };
|
||||
bool m_should_announce_exit { false };
|
||||
|
|
|
@ -1069,7 +1069,7 @@ AST::MatchEntry Parser::parse_match_entry()
|
|||
if (names.is_empty()) {
|
||||
for (auto& name : regex.parser_result.capture_groups)
|
||||
names.append(TRY_OR(
|
||||
String::from_deprecated_string(name),
|
||||
String::from_byte_string(name),
|
||||
error = create<AST::SyntaxError>(MUST(String::from_utf8(_error.string_literal())));
|
||||
break;));
|
||||
} else {
|
||||
|
@ -1077,7 +1077,7 @@ AST::MatchEntry Parser::parse_match_entry()
|
|||
for (auto& name : regex.parser_result.capture_groups) {
|
||||
if (names.size() <= index) {
|
||||
names.append(TRY_OR(
|
||||
String::from_deprecated_string(name),
|
||||
String::from_byte_string(name),
|
||||
error = create<AST::SyntaxError>(MUST(String::from_utf8(_error.string_literal())));
|
||||
break;));
|
||||
continue;
|
||||
|
|
|
@ -598,7 +598,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_start()
|
|||
if (m_state.escaping && consume_specific('\n')) {
|
||||
m_state.escaping = false;
|
||||
|
||||
auto buffer = m_state.buffer.to_deprecated_string().substring(0, m_state.buffer.length() - 1);
|
||||
auto buffer = m_state.buffer.to_byte_string().substring(0, m_state.buffer.length() - 1);
|
||||
m_state.buffer.clear();
|
||||
m_state.buffer.append(buffer);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ struct ResolvedParameterExpansion {
|
|||
Word,
|
||||
} expand { Expand::Nothing };
|
||||
|
||||
DeprecatedString to_deprecated_string() const
|
||||
ByteString to_byte_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("{"sv);
|
||||
|
@ -171,7 +171,7 @@ struct ResolvedParameterExpansion {
|
|||
builder.append(argument);
|
||||
builder.append(")"sv);
|
||||
builder.append("}"sv);
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -144,20 +144,20 @@ ErrorOr<void> Parser::fill_token_buffer(Optional<Reduction> starting_reduction)
|
|||
if (!token.has_value())
|
||||
break;
|
||||
#if SHELL_POSIX_PARSER_DEBUG
|
||||
DeprecatedString position = "(~)";
|
||||
ByteString position = "(~)";
|
||||
if (token->position.has_value())
|
||||
position = DeprecatedString::formatted("{}:{}", token->position->start_offset, token->position->end_offset);
|
||||
DeprecatedString expansions = "";
|
||||
position = ByteString::formatted("{}:{}", token->position->start_offset, token->position->end_offset);
|
||||
ByteString expansions = "";
|
||||
for (auto& exp : token->resolved_expansions)
|
||||
exp.visit(
|
||||
[&](ResolvedParameterExpansion& x) { expansions = DeprecatedString::formatted("{}param({}),", expansions, x.to_deprecated_string()); },
|
||||
[&](ResolvedCommandExpansion& x) { expansions = DeprecatedString::formatted("{}command({:p})", expansions, x.command.ptr()); },
|
||||
[&](ResolvedArithmeticExpansion& x) { expansions = DeprecatedString::formatted("{}arith({})", expansions, x.source_expression); });
|
||||
DeprecatedString rexpansions = "";
|
||||
[&](ResolvedParameterExpansion& x) { expansions = ByteString::formatted("{}param({}),", expansions, x.to_byte_string()); },
|
||||
[&](ResolvedCommandExpansion& x) { expansions = ByteString::formatted("{}command({:p})", expansions, x.command.ptr()); },
|
||||
[&](ResolvedArithmeticExpansion& x) { expansions = ByteString::formatted("{}arith({})", expansions, x.source_expression); });
|
||||
ByteString rexpansions = "";
|
||||
for (auto& exp : token->expansions)
|
||||
exp.visit(
|
||||
[&](ParameterExpansion& x) { rexpansions = DeprecatedString::formatted("{}param({}) from {} to {},", rexpansions, x.parameter.string_view(), x.range.start, x.range.length); },
|
||||
[&](auto&) { rexpansions = DeprecatedString::formatted("{}...,", rexpansions); });
|
||||
[&](ParameterExpansion& x) { rexpansions = ByteString::formatted("{}param({}) from {} to {},", rexpansions, x.parameter.string_view(), x.range.start, x.range.length); },
|
||||
[&](auto&) { rexpansions = ByteString::formatted("{}...,", rexpansions); });
|
||||
dbgln("Token @ {}: '{}' (type {}) - parsed expansions: {} - raw expansions: {}", position, token->value.replace("\n"sv, "\\n"sv, ReplaceMode::All), token->type_name(), expansions, rexpansions);
|
||||
#endif
|
||||
}
|
||||
|
@ -1845,7 +1845,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
for (auto& expansion : token.resolved_expansions) {
|
||||
TRY(expansion.visit(
|
||||
[&](ResolvedParameterExpansion const& x) -> ErrorOr<void> {
|
||||
dbgln_if(SHELL_POSIX_PARSER_DEBUG, " Expanding '{}' ({}+{})", x.to_deprecated_string(), x.range.start, x.range.length);
|
||||
dbgln_if(SHELL_POSIX_PARSER_DEBUG, " Expanding '{}' ({}+{})", x.to_byte_string(), x.range.start, x.range.length);
|
||||
if (x.range.start >= value_bytes.length()) {
|
||||
dbgln("Parameter expansion range {}-{} is out of bounds for '{}'", x.range.start, x.range.length, value_bytes);
|
||||
return {};
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
RefPtr<AST::Node> parse_word_list(AllowNewlines = AllowNewlines::No);
|
||||
|
||||
struct Error {
|
||||
DeprecatedString message;
|
||||
ByteString message;
|
||||
Optional<AST::Position> position;
|
||||
};
|
||||
auto& errors() const { return m_errors; }
|
||||
|
@ -106,7 +106,7 @@ private:
|
|||
void error(Token const& token, CheckedFormatString<Ts...> fmt, Ts&&... args)
|
||||
{
|
||||
m_errors.append(Error {
|
||||
DeprecatedString::formatted(fmt.view(), forward<Ts>(args)...),
|
||||
ByteString::formatted(fmt.view(), forward<Ts>(args)...),
|
||||
token.position,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ void Shell::print_path(StringView path)
|
|||
out("\033]8;;{}\033\\{}\033]8;;\033\\", url.serialize(), path);
|
||||
}
|
||||
|
||||
DeprecatedString Shell::prompt() const
|
||||
ByteString Shell::prompt() const
|
||||
{
|
||||
if (m_next_scheduled_prompt_text.has_value())
|
||||
return m_next_scheduled_prompt_text.release_value();
|
||||
|
@ -93,7 +93,7 @@ DeprecatedString Shell::prompt() const
|
|||
StringBuilder builder;
|
||||
builder.appendff("\033]0;{}@{}:{}\007", username, hostname, cwd);
|
||||
builder.appendff("\033[31;1m{}\033[0m@\033[37;1m{}\033[0m:\033[32;1m{}\033[0m$> ", username, hostname, cwd);
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
|
@ -121,7 +121,7 @@ DeprecatedString Shell::prompt() const
|
|||
builder.append({ hostname, strlen(hostname) });
|
||||
|
||||
} else if (lexer.consume_specific('w') || lexer.consume_specific('W')) {
|
||||
DeprecatedString const home_path = getenv("HOME");
|
||||
ByteString const 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()));
|
||||
|
@ -139,7 +139,7 @@ DeprecatedString Shell::prompt() const
|
|||
|
||||
auto const max_component_count = number_string.to_uint().value();
|
||||
|
||||
DeprecatedString const home_path = getenv("HOME");
|
||||
ByteString const home_path = getenv("HOME");
|
||||
|
||||
auto const should_collapse_path = cwd.starts_with(home_path);
|
||||
auto const should_use_ellipsis = (next_char == 'w');
|
||||
|
@ -172,13 +172,13 @@ DeprecatedString Shell::prompt() const
|
|||
builder.append(uid == 0 ? '#' : '$');
|
||||
|
||||
} else if (lexer.consume_specific('t')) {
|
||||
builder.append(Core::DateTime::now().to_deprecated_string("%H:%M:%S"sv));
|
||||
builder.append(Core::DateTime::now().to_byte_string("%H:%M:%S"sv));
|
||||
|
||||
} else if (lexer.consume_specific('T')) {
|
||||
builder.append(Core::DateTime::now().to_deprecated_string("%I:%M:%S"sv));
|
||||
builder.append(Core::DateTime::now().to_byte_string("%I:%M:%S"sv));
|
||||
|
||||
} else if (lexer.consume_specific('@')) {
|
||||
builder.append(Core::DateTime::now().to_deprecated_string("%I:%M %p"sv));
|
||||
builder.append(Core::DateTime::now().to_byte_string("%I:%M %p"sv));
|
||||
|
||||
} else if (lexer.consume_specific("D{"sv)) {
|
||||
auto format = lexer.consume_until('}');
|
||||
|
@ -187,7 +187,7 @@ DeprecatedString Shell::prompt() const
|
|||
|
||||
if (format.is_empty())
|
||||
format = "%y-%m-%d"sv;
|
||||
builder.append(Core::DateTime::now().to_deprecated_string(format));
|
||||
builder.append(Core::DateTime::now().to_byte_string(format));
|
||||
|
||||
} else if (lexer.consume_specific('j')) {
|
||||
builder.appendff("{}", jobs.size());
|
||||
|
@ -205,10 +205,10 @@ DeprecatedString Shell::prompt() const
|
|||
lexer.consume();
|
||||
}
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString Shell::expand_tilde(StringView expression)
|
||||
ByteString Shell::expand_tilde(StringView expression)
|
||||
{
|
||||
VERIFY(expression.starts_with('~'));
|
||||
|
||||
|
@ -231,17 +231,17 @@ DeprecatedString Shell::expand_tilde(StringView expression)
|
|||
if (!home) {
|
||||
auto passwd = getpwuid(getuid());
|
||||
VERIFY(passwd && passwd->pw_dir);
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_deprecated_string());
|
||||
return ByteString::formatted("{}/{}", passwd->pw_dir, path.to_byte_string());
|
||||
}
|
||||
return DeprecatedString::formatted("{}/{}", home, path.to_deprecated_string());
|
||||
return ByteString::formatted("{}/{}", home, path.to_byte_string());
|
||||
}
|
||||
|
||||
auto passwd = getpwnam(login_name.to_deprecated_string().characters());
|
||||
auto passwd = getpwnam(login_name.to_byte_string().characters());
|
||||
if (!passwd)
|
||||
return expression;
|
||||
VERIFY(passwd->pw_dir);
|
||||
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_deprecated_string());
|
||||
return ByteString::formatted("{}/{}", passwd->pw_dir, path.to_byte_string());
|
||||
}
|
||||
|
||||
bool Shell::is_glob(StringView s)
|
||||
|
@ -254,7 +254,7 @@ bool Shell::is_glob(StringView s)
|
|||
return false;
|
||||
}
|
||||
|
||||
ErrorOr<Vector<DeprecatedString>> Shell::expand_globs(StringView path, StringView base)
|
||||
ErrorOr<Vector<ByteString>> Shell::expand_globs(StringView path, StringView base)
|
||||
{
|
||||
auto explicitly_set_base = false;
|
||||
if (path.starts_with('/')) {
|
||||
|
@ -288,10 +288,10 @@ ErrorOr<Vector<DeprecatedString>> Shell::expand_globs(StringView path, StringVie
|
|||
return results;
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> Shell::expand_globs(Vector<StringView> path_segments, StringView base)
|
||||
Vector<ByteString> Shell::expand_globs(Vector<StringView> path_segments, StringView base)
|
||||
{
|
||||
if (path_segments.is_empty()) {
|
||||
DeprecatedString base_str = base;
|
||||
ByteString base_str = base;
|
||||
struct stat statbuf;
|
||||
if (lstat(base_str.characters(), &statbuf) < 0)
|
||||
return {};
|
||||
|
@ -300,7 +300,7 @@ Vector<DeprecatedString> Shell::expand_globs(Vector<StringView> path_segments, S
|
|||
|
||||
auto first_segment = path_segments.take_first();
|
||||
if (is_glob(first_segment)) {
|
||||
Vector<DeprecatedString> result;
|
||||
Vector<ByteString> result;
|
||||
|
||||
auto const is_glob_directory = first_segment.ends_with('/');
|
||||
if (is_glob_directory)
|
||||
|
@ -389,12 +389,12 @@ ErrorOr<Vector<AST::Command>> Shell::expand_aliases(Vector<AST::Command> initial
|
|||
return commands;
|
||||
}
|
||||
|
||||
DeprecatedString Shell::resolve_path(DeprecatedString path) const
|
||||
ByteString Shell::resolve_path(ByteString path) const
|
||||
{
|
||||
if (!path.starts_with('/'))
|
||||
path = DeprecatedString::formatted("{}/{}", cwd, path);
|
||||
path = ByteString::formatted("{}/{}", cwd, path);
|
||||
|
||||
return FileSystem::real_path(path).release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
return FileSystem::real_path(path).release_value_but_fixme_should_propagate_errors().to_byte_string();
|
||||
}
|
||||
|
||||
Shell::LocalFrame* Shell::find_frame_containing_local_variable(StringView name)
|
||||
|
@ -421,7 +421,7 @@ ErrorOr<RefPtr<AST::Value const>> Shell::look_up_local_variable(StringView name)
|
|||
ErrorOr<RefPtr<AST::Value const>> Shell::get_argument(size_t index) const
|
||||
{
|
||||
if (index == 0) {
|
||||
auto current_script_string = TRY(String::from_deprecated_string(current_script));
|
||||
auto current_script_string = TRY(String::from_byte_string(current_script));
|
||||
return adopt_ref(*new AST::StringValue(current_script_string));
|
||||
}
|
||||
|
||||
|
@ -444,18 +444,18 @@ ErrorOr<RefPtr<AST::Value const>> Shell::get_argument(size_t index) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Shell::local_variable_or(StringView name, DeprecatedString const& replacement) const
|
||||
ErrorOr<ByteString> Shell::local_variable_or(StringView name, ByteString const& replacement) const
|
||||
{
|
||||
auto value = TRY(look_up_local_variable(name));
|
||||
if (value) {
|
||||
StringBuilder builder;
|
||||
builder.join(' ', TRY(const_cast<AST::Value&>(*value).resolve_as_list(const_cast<Shell&>(*this))));
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
||||
void Shell::set_local_variable(DeprecatedString const& name, RefPtr<AST::Value> value, bool only_in_current_frame)
|
||||
void Shell::set_local_variable(ByteString 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)) {
|
||||
|
@ -487,7 +487,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(DeprecatedString name, Vector<DeprecatedString> argnames, RefPtr<AST::Node> body)
|
||||
void Shell::define_function(ByteString name, Vector<ByteString> argnames, RefPtr<AST::Node> body)
|
||||
{
|
||||
add_entry_to_cache({ RunnablePath::Kind::Function, name });
|
||||
m_functions.set(name, { name, move(argnames), move(body) });
|
||||
|
@ -505,7 +505,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
|
|||
|
||||
StringView name = command.argv.first();
|
||||
|
||||
TemporaryChange<DeprecatedString> script_change { current_script, name };
|
||||
TemporaryChange<ByteString> script_change { current_script, name };
|
||||
|
||||
auto function_option = m_functions.get(name);
|
||||
if (!function_option.has_value())
|
||||
|
@ -519,12 +519,12 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
|
|||
}
|
||||
|
||||
if (command.argv.size() - 1 < function.arguments.size()) {
|
||||
raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected at least {} arguments to {}, but got {}", function.arguments.size(), function.name, command.argv.size() - 1), command.position);
|
||||
raise_error(ShellError::EvaluatedSyntaxError, ByteString::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(DeprecatedString::formatted("function {}", function.name), LocalFrameKind::FunctionOrGlobal);
|
||||
auto frame = push_frame(ByteString::formatted("function {}", function.name), LocalFrameKind::FunctionOrGlobal);
|
||||
size_t index = 0;
|
||||
for (auto& arg : function.arguments) {
|
||||
++index;
|
||||
|
@ -547,7 +547,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
|
|||
return true;
|
||||
}
|
||||
|
||||
DeprecatedString Shell::format(StringView source, ssize_t& cursor) const
|
||||
ByteString Shell::format(StringView source, ssize_t& cursor) const
|
||||
{
|
||||
Formatter formatter(source, cursor, m_in_posix_mode);
|
||||
auto result = formatter.format();
|
||||
|
@ -556,7 +556,7 @@ DeprecatedString Shell::format(StringView source, ssize_t& cursor) const
|
|||
return result;
|
||||
}
|
||||
|
||||
Shell::Frame Shell::push_frame(DeprecatedString name, Shell::LocalFrameKind kind)
|
||||
Shell::Frame Shell::push_frame(ByteString name, Shell::LocalFrameKind kind)
|
||||
{
|
||||
m_local_frames.append(make<LocalFrame>(name, decltype(LocalFrame::local_variables) {}, kind));
|
||||
dbgln_if(SH_DEBUG, "New frame '{}' at {:p}", name, &m_local_frames.last());
|
||||
|
@ -583,7 +583,7 @@ Shell::Frame::~Frame()
|
|||
(void)frames.take_last();
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> Shell::resolve_alias(StringView name) const
|
||||
Optional<ByteString> Shell::resolve_alias(StringView name) const
|
||||
{
|
||||
return m_aliases.get(name);
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ Optional<Shell::RunnablePath> Shell::runnable_path_for(StringView name)
|
|||
return *found;
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> Shell::help_path_for(Vector<RunnablePath> visited, Shell::RunnablePath const& runnable_path)
|
||||
Optional<ByteString> Shell::help_path_for(Vector<RunnablePath> visited, Shell::RunnablePath const& runnable_path)
|
||||
{
|
||||
switch (runnable_path.kind) {
|
||||
case RunnablePath::Kind::Executable: {
|
||||
|
@ -806,11 +806,11 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
|
|||
}
|
||||
|
||||
Vector<char const*> argv;
|
||||
Vector<DeprecatedString> copy_argv;
|
||||
Vector<ByteString> copy_argv;
|
||||
argv.ensure_capacity(command.argv.size() + 1);
|
||||
|
||||
for (auto& arg : command.argv) {
|
||||
copy_argv.append(arg.to_deprecated_string());
|
||||
copy_argv.append(arg.to_byte_string());
|
||||
argv.append(copy_argv.last().characters());
|
||||
}
|
||||
|
||||
|
@ -920,7 +920,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
|
|||
// as the child will run this chain.
|
||||
if (command.should_immediately_execute_next)
|
||||
command_copy.next_chain.clear();
|
||||
auto job = Job::create(child, pgid, cmd.to_deprecated_string(), find_last_job_id() + 1, move(command_copy));
|
||||
auto job = Job::create(child, pgid, cmd.to_byte_string(), find_last_job_id() + 1, move(command_copy));
|
||||
jobs.set((u64)child, job);
|
||||
|
||||
job->on_exit = [this](auto job) {
|
||||
|
@ -951,7 +951,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
|
|||
|
||||
ErrorOr<void> Shell::execute_process(Span<StringView> argv)
|
||||
{
|
||||
Vector<DeprecatedString> strings;
|
||||
Vector<ByteString> strings;
|
||||
Vector<char const*> args;
|
||||
TRY(strings.try_ensure_capacity(argv.size()));
|
||||
TRY(args.try_ensure_capacity(argv.size() + 1));
|
||||
|
@ -1016,7 +1016,7 @@ void Shell::execute_process(Vector<char const*>&& argv)
|
|||
if (!line.starts_with("#!"sv))
|
||||
break;
|
||||
GenericLexer shebang_lexer { line.substring_view(2) };
|
||||
auto shebang = shebang_lexer.consume_until(is_any_of("\n\r"sv)).to_deprecated_string();
|
||||
auto shebang = shebang_lexer.consume_until(is_any_of("\n\r"sv)).to_byte_string();
|
||||
argv.prepend(shebang.characters());
|
||||
int rc = execvp(argv[0], const_cast<char* const*>(argv.data()));
|
||||
if (rc < 0) {
|
||||
|
@ -1114,7 +1114,7 @@ Vector<NonnullRefPtr<Job>> Shell::run_commands(Vector<AST::Command>& commands)
|
|||
}
|
||||
auto job_result = run_command(command);
|
||||
if (job_result.is_error()) {
|
||||
raise_error(ShellError::LaunchError, DeprecatedString::formatted("{} while running '{}'", job_result.error(), command.argv.first()), command.position);
|
||||
raise_error(ShellError::LaunchError, ByteString::formatted("{} while running '{}'", job_result.error(), command.argv.first()), command.position);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ Vector<NonnullRefPtr<Job>> Shell::run_commands(Vector<AST::Command>& commands)
|
|||
return spawned_jobs;
|
||||
}
|
||||
|
||||
bool Shell::run_file(DeprecatedString const& filename, bool explicitly_invoked)
|
||||
bool Shell::run_file(ByteString const& filename, bool explicitly_invoked)
|
||||
{
|
||||
TemporaryChange script_change { current_script, filename };
|
||||
TemporaryChange interactive_change { m_is_interactive, false };
|
||||
|
@ -1149,7 +1149,7 @@ bool Shell::run_file(DeprecatedString const& filename, bool explicitly_invoked)
|
|||
|
||||
auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
auto error = DeprecatedString::formatted("'{}': {}", escape_token_for_single_quotes(filename), file_or_error.error());
|
||||
auto error = ByteString::formatted("'{}': {}", escape_token_for_single_quotes(filename), file_or_error.error());
|
||||
if (explicitly_invoked)
|
||||
raise_error(ShellError::OpenFailure, error);
|
||||
else
|
||||
|
@ -1159,7 +1159,7 @@ bool Shell::run_file(DeprecatedString const& filename, bool explicitly_invoked)
|
|||
auto file = file_or_error.release_value();
|
||||
auto data_or_error = file->read_until_eof();
|
||||
if (data_or_error.is_error()) {
|
||||
auto error = DeprecatedString::formatted("'{}': {}", escape_token_for_single_quotes(filename), data_or_error.error());
|
||||
auto error = ByteString::formatted("'{}': {}", escape_token_for_single_quotes(filename), data_or_error.error());
|
||||
if (explicitly_invoked)
|
||||
raise_error(ShellError::OpenFailure, error);
|
||||
else
|
||||
|
@ -1242,14 +1242,14 @@ void Shell::block_on_job(RefPtr<Job> job)
|
|||
block_on_pipeline(command->pipeline);
|
||||
}
|
||||
|
||||
DeprecatedString Shell::get_history_path()
|
||||
ByteString Shell::get_history_path()
|
||||
{
|
||||
if (auto histfile = getenv("HISTFILE"))
|
||||
return { histfile };
|
||||
return DeprecatedString::formatted("{}/.history", home);
|
||||
return ByteString::formatted("{}/.history", home);
|
||||
}
|
||||
|
||||
DeprecatedString Shell::escape_token_for_single_quotes(StringView token)
|
||||
ByteString Shell::escape_token_for_single_quotes(StringView token)
|
||||
{
|
||||
// `foo bar \n '` -> `'foo bar \n '"'"`
|
||||
|
||||
|
@ -1276,10 +1276,10 @@ DeprecatedString Shell::escape_token_for_single_quotes(StringView token)
|
|||
if (started_single_quote)
|
||||
builder.append("'"sv);
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString Shell::escape_token_for_double_quotes(StringView token)
|
||||
ByteString Shell::escape_token_for_double_quotes(StringView token)
|
||||
{
|
||||
// `foo bar \n $x 'blah "hello` -> `"foo bar \\n $x 'blah \"hello"`
|
||||
|
||||
|
@ -1302,7 +1302,7 @@ DeprecatedString Shell::escape_token_for_double_quotes(StringView token)
|
|||
|
||||
builder.append('"');
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
Shell::SpecialCharacterEscapeMode Shell::special_character_escape_mode(u32 code_point, EscapeMode mode)
|
||||
|
@ -1346,7 +1346,7 @@ Shell::SpecialCharacterEscapeMode Shell::special_character_escape_mode(u32 code_
|
|||
}
|
||||
|
||||
template<typename... Offsets>
|
||||
static DeprecatedString do_escape(Shell::EscapeMode escape_mode, auto& token, Offsets&... offsets)
|
||||
static ByteString do_escape(Shell::EscapeMode escape_mode, auto& token, Offsets&... offsets)
|
||||
{
|
||||
StringBuilder builder;
|
||||
size_t offset_from_original = 0;
|
||||
|
@ -1431,15 +1431,15 @@ static DeprecatedString do_escape(Shell::EscapeMode escape_mode, auto& token, Of
|
|||
}
|
||||
}
|
||||
check_offsets();
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString Shell::escape_token(Utf32View token, EscapeMode escape_mode)
|
||||
ByteString Shell::escape_token(Utf32View token, EscapeMode escape_mode)
|
||||
{
|
||||
return do_escape(escape_mode, token);
|
||||
}
|
||||
|
||||
DeprecatedString Shell::escape_token(StringView token, EscapeMode escape_mode)
|
||||
ByteString Shell::escape_token(StringView token, EscapeMode escape_mode)
|
||||
{
|
||||
Utf8View view { token };
|
||||
if (view.validate())
|
||||
|
@ -1447,7 +1447,7 @@ DeprecatedString Shell::escape_token(StringView token, EscapeMode escape_mode)
|
|||
return do_escape(escape_mode, token);
|
||||
}
|
||||
|
||||
DeprecatedString Shell::unescape_token(StringView token)
|
||||
ByteString Shell::unescape_token(StringView token)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -1474,7 +1474,7 @@ DeprecatedString Shell::unescape_token(StringView token)
|
|||
if (state == Escaped)
|
||||
builder.append('\\');
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
void Shell::cache_path()
|
||||
|
@ -1506,14 +1506,14 @@ void Shell::cache_path()
|
|||
}
|
||||
|
||||
// TODO: Can we make this rely on Core::System::resolve_executable_from_environment()?
|
||||
DeprecatedString path = getenv("PATH");
|
||||
ByteString 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 = DeprecatedString::formatted("{}/{}", directory, program);
|
||||
auto program_path = ByteString::formatted("{}/{}", directory, program);
|
||||
auto escaped_name = escape_token(program);
|
||||
if (cached_path.contains_slow(escaped_name))
|
||||
continue;
|
||||
|
@ -1577,7 +1577,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;
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
|
||||
ssize_t last_slash = token.length() - 1;
|
||||
while (last_slash >= 0 && token[last_slash] != '/')
|
||||
|
@ -1615,7 +1615,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_path(StringView base, StringV
|
|||
path_builder.append('/');
|
||||
path_builder.append(init_slash_part);
|
||||
}
|
||||
path = path_builder.to_deprecated_string();
|
||||
path = path_builder.to_byte_string();
|
||||
token = last_slash_part;
|
||||
|
||||
// the invariant part of the token is actually just the last segment
|
||||
|
@ -1638,7 +1638,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 = DeprecatedString::formatted("{}/{}", path, file);
|
||||
auto file_path = ByteString::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)) {
|
||||
|
@ -1678,7 +1678,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_program_name(StringView name,
|
|||
if (!match)
|
||||
return complete_path(""sv, name, offset, ExecutableOnly::Yes, nullptr, nullptr, escape_mode);
|
||||
|
||||
DeprecatedString completion = match->path;
|
||||
ByteString completion = match->path;
|
||||
auto token_length = escape_token(name, escape_mode).length();
|
||||
auto invariant_offset = token_length;
|
||||
size_t static_offset = 0;
|
||||
|
@ -1732,7 +1732,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_variable(StringView name, siz
|
|||
auto parts = entry.split_view('=');
|
||||
if (parts.is_empty() || parts.first().is_empty())
|
||||
continue;
|
||||
DeprecatedString name = parts.first();
|
||||
ByteString name = parts.first();
|
||||
if (suggestions.contains_slow(name))
|
||||
continue;
|
||||
suggestions.append(move(name));
|
||||
|
@ -1764,7 +1764,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_user(StringView name, size_t
|
|||
return suggestions;
|
||||
|
||||
while (di.has_next()) {
|
||||
DeprecatedString name = di.next_path();
|
||||
ByteString name = di.next_path();
|
||||
if (name.starts_with(pattern)) {
|
||||
suggestions.append(name);
|
||||
auto& suggestion = suggestions.last();
|
||||
|
@ -2029,27 +2029,27 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
|
|||
auto parsed = parsed_result.release_value();
|
||||
if (parsed.is_object()) {
|
||||
auto& object = parsed.as_object();
|
||||
auto kind = object.get_deprecated_string("kind"sv).value_or("plain");
|
||||
auto kind = object.get_byte_string("kind"sv).value_or("plain");
|
||||
if (kind == "path") {
|
||||
auto base = object.get_deprecated_string("base"sv).value_or("");
|
||||
auto part = object.get_deprecated_string("part"sv).value_or("");
|
||||
auto base = object.get_byte_string("base"sv).value_or("");
|
||||
auto part = object.get_byte_string("part"sv).value_or("");
|
||||
auto executable_only = object.get_bool("executable_only"sv).value_or(false) ? ExecutableOnly::Yes : ExecutableOnly::No;
|
||||
suggestions.extend(complete_path(base, part, part.length(), executable_only, nullptr, nullptr));
|
||||
} else if (kind == "program") {
|
||||
auto name = object.get_deprecated_string("name"sv).value_or("");
|
||||
auto name = object.get_byte_string("name"sv).value_or("");
|
||||
suggestions.extend(complete_program_name(name, name.length()));
|
||||
} else if (kind == "proxy") {
|
||||
if (m_completion_stack_info.size_free() < 4 * KiB) {
|
||||
dbgln("Not enough stack space, recursion?");
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
auto argv = object.get_deprecated_string("argv"sv).value_or("");
|
||||
auto argv = object.get_byte_string("argv"sv).value_or("");
|
||||
dbgln("Proxy completion for {}", argv);
|
||||
suggestions.extend(complete(argv));
|
||||
} else if (kind == "plain") {
|
||||
auto completion_text = object.get_deprecated_string("completion"sv).value_or("");
|
||||
auto trailing_text = object.get_deprecated_string("trailing_trivia"sv).value_or("");
|
||||
auto display_text = object.get_deprecated_string("display_trivia"sv).value_or("");
|
||||
auto completion_text = object.get_byte_string("completion"sv).value_or("");
|
||||
auto trailing_text = object.get_byte_string("trailing_trivia"sv).value_or("");
|
||||
auto display_text = object.get_byte_string("display_trivia"sv).value_or("");
|
||||
auto static_offset = object.get_u64("static_offset"sv).value_or(0);
|
||||
auto invariant_offset = object.get_u64("invariant_offset"sv).value_or(0);
|
||||
if (!object.get_bool("treat_as_code"sv).value_or(false)) {
|
||||
|
@ -2067,7 +2067,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
|
|||
dbgln("LibLine: Unhandled completion kind: {}", kind);
|
||||
}
|
||||
} else {
|
||||
suggestions.append(parsed.to_deprecated_string());
|
||||
suggestions.append(parsed.to_byte_string());
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
|
@ -2123,7 +2123,7 @@ void Shell::bring_cursor_to_beginning_of_a_line() const
|
|||
// Black with Cyan background.
|
||||
constexpr auto default_mark = "\e[30;46m%\e[0m";
|
||||
auto eol_mark_ptr = getenv("PROMPT_EOL_MARK");
|
||||
DeprecatedString eol_mark = eol_mark_ptr ?: default_mark;
|
||||
ByteString eol_mark = eol_mark_ptr ?: default_mark;
|
||||
size_t eol_mark_length = Line::Editor::actual_rendered_string_metrics(eol_mark).line_metrics.last().total_length();
|
||||
if (eol_mark_length >= ws.ws_col) {
|
||||
eol_mark = default_mark;
|
||||
|
@ -2135,7 +2135,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 = DeprecatedString::repeated(' ', fill_count);
|
||||
auto fill_buffer = ByteString::repeated(' ', fill_count);
|
||||
fwrite(fill_buffer.characters(), 1, fill_count, stderr);
|
||||
|
||||
putc('\r', stderr);
|
||||
|
@ -2351,7 +2351,7 @@ Shell::Shell()
|
|||
if (path.length())
|
||||
path.append(":"sv);
|
||||
path.append(DEFAULT_PATH_SV);
|
||||
setenv("PATH", path.to_deprecated_string().characters(), true);
|
||||
setenv("PATH", path.to_byte_string().characters(), true);
|
||||
}
|
||||
|
||||
cache_path();
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include "Job.h"
|
||||
#include "Parser.h"
|
||||
#include <AK/Array.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/StackInfo.h>
|
||||
|
@ -119,8 +119,8 @@ public:
|
|||
void setup_keybinds();
|
||||
|
||||
struct SourcePosition {
|
||||
Optional<DeprecatedString> source_file;
|
||||
DeprecatedString literal_source_text;
|
||||
Optional<ByteString> source_file;
|
||||
ByteString literal_source_text;
|
||||
Optional<AST::Position> position;
|
||||
};
|
||||
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
};
|
||||
|
||||
Kind kind;
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
|
||||
bool operator<(RunnablePath const& other) const
|
||||
{
|
||||
|
@ -169,38 +169,38 @@ public:
|
|||
|
||||
int run_command(StringView, Optional<SourcePosition> = {});
|
||||
Optional<RunnablePath> runnable_path_for(StringView);
|
||||
Optional<DeprecatedString> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path);
|
||||
Optional<ByteString> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path);
|
||||
ErrorOr<RefPtr<Job>> run_command(const AST::Command&);
|
||||
Vector<NonnullRefPtr<Job>> run_commands(Vector<AST::Command>&);
|
||||
bool run_file(DeprecatedString const&, bool explicitly_invoked = true);
|
||||
bool run_file(ByteString const&, bool explicitly_invoked = true);
|
||||
ErrorOr<bool> run_builtin(const AST::Command&, Vector<NonnullRefPtr<AST::Rewiring>> const&, int& retval);
|
||||
bool has_builtin(StringView) const;
|
||||
ErrorOr<RefPtr<AST::Node>> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&);
|
||||
static bool has_immediate_function(StringView);
|
||||
void block_on_job(RefPtr<Job>);
|
||||
void block_on_pipeline(RefPtr<AST::Pipeline>);
|
||||
DeprecatedString prompt() const;
|
||||
ByteString prompt() const;
|
||||
|
||||
static DeprecatedString expand_tilde(StringView expression);
|
||||
static ErrorOr<Vector<DeprecatedString>> expand_globs(StringView path, StringView base);
|
||||
static Vector<DeprecatedString> expand_globs(Vector<StringView> path_segments, StringView base);
|
||||
static ByteString expand_tilde(StringView expression);
|
||||
static ErrorOr<Vector<ByteString>> expand_globs(StringView path, StringView base);
|
||||
static Vector<ByteString> expand_globs(Vector<StringView> path_segments, StringView base);
|
||||
ErrorOr<Vector<AST::Command>> expand_aliases(Vector<AST::Command>);
|
||||
DeprecatedString resolve_path(DeprecatedString) const;
|
||||
Optional<DeprecatedString> resolve_alias(StringView) const;
|
||||
ByteString resolve_path(ByteString) const;
|
||||
Optional<ByteString> resolve_alias(StringView) const;
|
||||
|
||||
static bool has_history_event(StringView);
|
||||
|
||||
ErrorOr<RefPtr<AST::Value const>> get_argument(size_t) const;
|
||||
ErrorOr<RefPtr<AST::Value const>> look_up_local_variable(StringView) const;
|
||||
ErrorOr<DeprecatedString> local_variable_or(StringView, DeprecatedString const&) const;
|
||||
void set_local_variable(DeprecatedString const&, RefPtr<AST::Value>, bool only_in_current_frame = false);
|
||||
ErrorOr<ByteString> local_variable_or(StringView, ByteString const&) const;
|
||||
void set_local_variable(ByteString const&, RefPtr<AST::Value>, bool only_in_current_frame = false);
|
||||
void unset_local_variable(StringView, bool only_in_current_frame = false);
|
||||
|
||||
void define_function(DeprecatedString name, Vector<DeprecatedString> argnames, RefPtr<AST::Node> body);
|
||||
void define_function(ByteString name, Vector<ByteString> argnames, RefPtr<AST::Node> body);
|
||||
bool has_function(StringView);
|
||||
bool invoke_function(const AST::Command&, int& retval);
|
||||
|
||||
DeprecatedString format(StringView, ssize_t& cursor) const;
|
||||
ByteString format(StringView, ssize_t& cursor) const;
|
||||
|
||||
RefPtr<Line::Editor> editor() const { return m_editor; }
|
||||
|
||||
|
@ -209,15 +209,15 @@ public:
|
|||
Block,
|
||||
};
|
||||
struct LocalFrame {
|
||||
LocalFrame(DeprecatedString name, HashMap<DeprecatedString, RefPtr<AST::Value>> variables, LocalFrameKind kind = LocalFrameKind::Block)
|
||||
LocalFrame(ByteString name, HashMap<ByteString, RefPtr<AST::Value>> variables, LocalFrameKind kind = LocalFrameKind::Block)
|
||||
: name(move(name))
|
||||
, local_variables(move(variables))
|
||||
, is_function_frame(kind == LocalFrameKind::FunctionOrGlobal)
|
||||
{
|
||||
}
|
||||
|
||||
DeprecatedString name;
|
||||
HashMap<DeprecatedString, RefPtr<AST::Value>> local_variables;
|
||||
ByteString name;
|
||||
HashMap<ByteString, RefPtr<AST::Value>> local_variables;
|
||||
bool is_function_frame;
|
||||
};
|
||||
|
||||
|
@ -237,16 +237,16 @@ public:
|
|||
bool should_destroy_frame { true };
|
||||
};
|
||||
|
||||
[[nodiscard]] Frame push_frame(DeprecatedString name, LocalFrameKind = LocalFrameKind::Block);
|
||||
[[nodiscard]] Frame push_frame(ByteString name, LocalFrameKind = LocalFrameKind::Block);
|
||||
void pop_frame();
|
||||
|
||||
struct Promise {
|
||||
struct Data {
|
||||
struct Unveil {
|
||||
DeprecatedString path;
|
||||
DeprecatedString access;
|
||||
ByteString path;
|
||||
ByteString access;
|
||||
};
|
||||
DeprecatedString exec_promises;
|
||||
ByteString exec_promises;
|
||||
Vector<Unveil> unveils;
|
||||
} data;
|
||||
|
||||
|
@ -280,11 +280,11 @@ public:
|
|||
SingleQuotedString,
|
||||
DoubleQuotedString,
|
||||
};
|
||||
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);
|
||||
static ByteString escape_token_for_double_quotes(StringView token);
|
||||
static ByteString escape_token_for_single_quotes(StringView token);
|
||||
static ByteString escape_token(StringView token, EscapeMode = EscapeMode::Bareword);
|
||||
static ByteString escape_token(Utf32View token, EscapeMode = EscapeMode::Bareword);
|
||||
static ByteString unescape_token(StringView token);
|
||||
enum class SpecialCharacterEscapeMode {
|
||||
Untouched,
|
||||
Escaped,
|
||||
|
@ -319,7 +319,7 @@ public:
|
|||
Job* current_job() const { return m_current_job; }
|
||||
void kill_job(Job const*, int sig);
|
||||
|
||||
DeprecatedString get_history_path();
|
||||
ByteString get_history_path();
|
||||
void print_path(StringView path);
|
||||
void cache_path();
|
||||
|
||||
|
@ -334,9 +334,9 @@ public:
|
|||
bool was_interrupted { false };
|
||||
bool was_resized { false };
|
||||
|
||||
DeprecatedString cwd;
|
||||
DeprecatedString username;
|
||||
DeprecatedString home;
|
||||
ByteString cwd;
|
||||
ByteString username;
|
||||
ByteString home;
|
||||
|
||||
constexpr static auto TTYNameSize = 32;
|
||||
constexpr static auto HostNameSize = 64;
|
||||
|
@ -346,12 +346,12 @@ public:
|
|||
|
||||
uid_t uid;
|
||||
Optional<int> last_return_code;
|
||||
Vector<DeprecatedString> directory_stack;
|
||||
CircularQueue<DeprecatedString, 8> cd_history; // FIXME: have a configurable cd history length
|
||||
Vector<ByteString> directory_stack;
|
||||
CircularQueue<ByteString, 8> cd_history; // FIXME: have a configurable cd history length
|
||||
HashMap<u64, NonnullRefPtr<Job>> jobs;
|
||||
Vector<RunnablePath, 256> cached_path;
|
||||
|
||||
DeprecatedString current_script;
|
||||
ByteString current_script;
|
||||
|
||||
enum ShellEventType {
|
||||
ReadLine,
|
||||
|
@ -375,7 +375,7 @@ public:
|
|||
WriteFailure,
|
||||
};
|
||||
|
||||
void raise_error(ShellError kind, DeprecatedString description, Optional<AST::Position> position = {})
|
||||
void raise_error(ShellError kind, ByteString description, Optional<AST::Position> position = {})
|
||||
{
|
||||
m_error = kind;
|
||||
m_error_description = move(description);
|
||||
|
@ -384,7 +384,7 @@ public:
|
|||
}
|
||||
bool has_error(ShellError err) const { return m_error == err; }
|
||||
bool has_any_error() const { return !has_error(ShellError::None); }
|
||||
DeprecatedString const& error_description() const { return m_error_description; }
|
||||
ByteString const& error_description() const { return m_error_description; }
|
||||
ShellError take_error()
|
||||
{
|
||||
auto err = m_error;
|
||||
|
@ -484,8 +484,8 @@ private:
|
|||
};
|
||||
|
||||
struct ShellFunction {
|
||||
DeprecatedString name;
|
||||
Vector<DeprecatedString> arguments;
|
||||
ByteString name;
|
||||
Vector<ByteString> arguments;
|
||||
RefPtr<AST::Node> body;
|
||||
};
|
||||
|
||||
|
@ -494,19 +494,19 @@ private:
|
|||
bool m_should_ignore_jobs_on_next_exit { false };
|
||||
pid_t m_pid { 0 };
|
||||
|
||||
HashMap<DeprecatedString, ShellFunction> m_functions;
|
||||
HashMap<ByteString, ShellFunction> m_functions;
|
||||
Vector<NonnullOwnPtr<LocalFrame>> m_local_frames;
|
||||
Promise::List m_active_promises;
|
||||
Vector<NonnullRefPtr<AST::Redirection>> m_global_redirections;
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString> m_aliases;
|
||||
HashMap<ByteString, ByteString> m_aliases;
|
||||
bool m_is_interactive { true };
|
||||
bool m_is_subshell { false };
|
||||
bool m_should_reinstall_signal_handlers { true };
|
||||
bool m_in_posix_mode { false };
|
||||
|
||||
ShellError m_error { ShellError::None };
|
||||
DeprecatedString m_error_description;
|
||||
ByteString m_error_description;
|
||||
Optional<SourcePosition> m_source_position;
|
||||
|
||||
bool m_should_format_live { false };
|
||||
|
@ -522,7 +522,7 @@ private:
|
|||
StackInfo m_completion_stack_info;
|
||||
|
||||
RefPtr<AST::Node> m_prompt_command_node;
|
||||
mutable Optional<DeprecatedString> m_next_scheduled_prompt_text;
|
||||
mutable Optional<ByteString> m_next_scheduled_prompt_text;
|
||||
};
|
||||
|
||||
[[maybe_unused]] static constexpr bool is_word_character(char c)
|
||||
|
@ -606,7 +606,7 @@ struct Traits<Shell::Shell::RunnablePath> : public DefaultTraits<Shell::Shell::R
|
|||
return self.path == other;
|
||||
}
|
||||
|
||||
static bool equals(Shell::Shell::RunnablePath const& self, DeprecatedString const& other)
|
||||
static bool equals(Shell::Shell::RunnablePath const& self, ByteString const& other)
|
||||
{
|
||||
return self.path == other;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
if (should_escape) {
|
||||
DeprecatedString escaped_string;
|
||||
ByteString escaped_string;
|
||||
Optional<char> trivia {};
|
||||
bool starting_trivia_already_provided = false;
|
||||
auto escape_mode = Shell::Shell::EscapeMode::Bareword;
|
||||
|
@ -227,7 +227,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!skip_rc_files) {
|
||||
auto run_rc_file = [&](auto& name) {
|
||||
DeprecatedString file_path = name;
|
||||
ByteString file_path = name;
|
||||
if (file_path.starts_with('~'))
|
||||
file_path = shell->expand_tilde(file_path);
|
||||
if (FileSystem::exists(file_path)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue