mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:07:40 +00:00
Shell: Convert String::format() => String::formatted()
This commit is contained in:
parent
f8dfc74f8b
commit
b41b6dd279
3 changed files with 17 additions and 17 deletions
|
@ -842,7 +842,7 @@ CastToList::~CastToList()
|
||||||
void CloseFdRedirection::dump(int level) const
|
void CloseFdRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
print_indented(String::format("%d -> Close", m_fd), level);
|
print_indented(String::formatted("{} -> Close", m_fd), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>)
|
RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>)
|
||||||
|
@ -1036,7 +1036,7 @@ DynamicEvaluate::~DynamicEvaluate()
|
||||||
void Fd2FdRedirection::dump(int level) const
|
void Fd2FdRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
print_indented(String::format("%d -> %d", m_old_fd, m_new_fd), level);
|
print_indented(String::formatted("{} -> {}", m_old_fd, m_new_fd), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> Fd2FdRedirection::run(RefPtr<Shell>)
|
RefPtr<Value> Fd2FdRedirection::run(RefPtr<Shell>)
|
||||||
|
@ -1066,10 +1066,10 @@ Fd2FdRedirection::~Fd2FdRedirection()
|
||||||
void FunctionDeclaration::dump(int level) const
|
void FunctionDeclaration::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
print_indented(String::format("(name: %s)\n", m_name.name.characters()), level + 1);
|
print_indented(String::formatted("(name: {})\n", m_name.name), level + 1);
|
||||||
print_indented("(argument namess)", level + 1);
|
print_indented("(argument names)", level + 1);
|
||||||
for (auto& arg : m_arguments)
|
for (auto& arg : m_arguments)
|
||||||
print_indented(String::format("(name: %s)\n", arg.name.characters()), level + 2);
|
print_indented(String::formatted("(name: {})\n", arg.name), level + 2);
|
||||||
|
|
||||||
print_indented("(body)", level + 1);
|
print_indented("(body)", level + 1);
|
||||||
if (m_block)
|
if (m_block)
|
||||||
|
@ -2319,7 +2319,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell
|
||||||
auto& position = m_path->position();
|
auto& position = m_path->position();
|
||||||
auto& path = path_text[0];
|
auto& path = path_text[0];
|
||||||
if (!path.starts_with('/'))
|
if (!path.starts_with('/'))
|
||||||
path = String::format("%s/%s", shell.cwd.characters(), path.characters());
|
path = String::formatted("{}/{}", shell.cwd, path);
|
||||||
auto url = URL::create_with_file_protocol(path);
|
auto url = URL::create_with_file_protocol(path);
|
||||||
url.set_host(shell.hostname);
|
url.set_host(shell.hostname);
|
||||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
||||||
|
@ -2478,7 +2478,7 @@ void ReadRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
m_path->dump(level + 1);
|
m_path->dump(level + 1);
|
||||||
print_indented(String::format("To %d", m_fd), level + 1);
|
print_indented(String::formatted("To {}", m_fd), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell)
|
RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell)
|
||||||
|
@ -2505,7 +2505,7 @@ void ReadWriteRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
m_path->dump(level + 1);
|
m_path->dump(level + 1);
|
||||||
print_indented(String::format("To/From %d", m_fd), level + 1);
|
print_indented(String::formatted("To/From {}", m_fd), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell)
|
RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell)
|
||||||
|
@ -3135,7 +3135,7 @@ void WriteAppendRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
m_path->dump(level + 1);
|
m_path->dump(level + 1);
|
||||||
print_indented(String::format("From %d", m_fd), level + 1);
|
print_indented(String::formatted("From {}", m_fd), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell)
|
RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell)
|
||||||
|
@ -3162,7 +3162,7 @@ void WriteRedirection::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
m_path->dump(level + 1);
|
m_path->dump(level + 1);
|
||||||
print_indented(String::format("From %d", m_fd), level + 1);
|
print_indented(String::formatted("From {}", m_fd), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell)
|
RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell)
|
||||||
|
|
|
@ -1782,7 +1782,7 @@ RefPtr<AST::Node> Parser::parse_glob()
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Allow composition of tilde+bareword with globs: '~/foo/bar/baz*'
|
// FIXME: Allow composition of tilde+bareword with globs: '~/foo/bar/baz*'
|
||||||
restore_to(saved_offset.offset, saved_offset.line);
|
restore_to(saved_offset.offset, saved_offset.line);
|
||||||
bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(String::format("Unexpected %s inside a glob", bareword_part->class_name().characters())));
|
bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Unexpected {} inside a glob", bareword_part->class_name())));
|
||||||
return bareword_part;
|
return bareword_part;
|
||||||
}
|
}
|
||||||
textbuilder.append(text);
|
textbuilder.append(text);
|
||||||
|
|
|
@ -171,9 +171,9 @@ String Shell::expand_tilde(const String& expression)
|
||||||
if (!home) {
|
if (!home) {
|
||||||
auto passwd = getpwuid(getuid());
|
auto passwd = getpwuid(getuid());
|
||||||
VERIFY(passwd && passwd->pw_dir);
|
VERIFY(passwd && passwd->pw_dir);
|
||||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
return String::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||||
}
|
}
|
||||||
return String::format("%s/%s", home, path.to_string().characters());
|
return String::formatted("{}/{}", home, path.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto passwd = getpwnam(login_name.to_string().characters());
|
auto passwd = getpwnam(login_name.to_string().characters());
|
||||||
|
@ -181,7 +181,7 @@ String Shell::expand_tilde(const String& expression)
|
||||||
return expression;
|
return expression;
|
||||||
VERIFY(passwd->pw_dir);
|
VERIFY(passwd->pw_dir);
|
||||||
|
|
||||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
return String::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Shell::is_glob(const StringView& s)
|
bool Shell::is_glob(const StringView& s)
|
||||||
|
@ -347,7 +347,7 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
|
||||||
String Shell::resolve_path(String path) const
|
String Shell::resolve_path(String path) const
|
||||||
{
|
{
|
||||||
if (!path.starts_with('/'))
|
if (!path.starts_with('/'))
|
||||||
path = String::format("%s/%s", cwd.characters(), path.characters());
|
path = String::formatted("{}/{}", cwd, path);
|
||||||
|
|
||||||
return Core::File::real_path_for(path);
|
return Core::File::real_path_for(path);
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1249,7 @@ void Shell::cache_path()
|
||||||
Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
|
Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
|
||||||
while (programs.has_next()) {
|
while (programs.has_next()) {
|
||||||
auto program = programs.next_path();
|
auto program = programs.next_path();
|
||||||
String program_path = String::format("%s/%s", directory.characters(), program.characters());
|
auto program_path = String::formatted("{}/{}", directory, program);
|
||||||
auto escaped_name = escape_token(program);
|
auto escaped_name = escape_token(program);
|
||||||
if (cached_path.contains_slow(escaped_name))
|
if (cached_path.contains_slow(escaped_name))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1357,7 +1357,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_path(const String& base,
|
||||||
auto file = files.next_path();
|
auto file = files.next_path();
|
||||||
if (file.starts_with(token)) {
|
if (file.starts_with(token)) {
|
||||||
struct stat program_status;
|
struct stat program_status;
|
||||||
String file_path = String::format("%s/%s", path.characters(), file.characters());
|
auto file_path = String::formatted("{}/{}", path, file);
|
||||||
int stat_error = stat(file_path.characters(), &program_status);
|
int stat_error = stat(file_path.characters(), &program_status);
|
||||||
if (!stat_error && (executable_only == ExecutableOnly::No || access(file_path.characters(), X_OK) == 0)) {
|
if (!stat_error && (executable_only == ExecutableOnly::No || access(file_path.characters(), X_OK) == 0)) {
|
||||||
if (S_ISDIR(program_status.st_mode)) {
|
if (S_ISDIR(program_status.st_mode)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue