1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

Shell: Convert StringBuilder::appendf() => AK::Format

This commit is contained in:
Andreas Kling 2021-05-07 20:45:21 +02:00
parent ea027834df
commit 8c3b603da3
3 changed files with 10 additions and 10 deletions

View file

@ -710,7 +710,7 @@ int Shell::builtin_pushd(int argc, const char** argv)
if (argv[1][0] == '/') { if (argv[1][0] == '/') {
path_builder.append(argv[1]); path_builder.append(argv[1]);
} else { } else {
path_builder.appendf("%s/%s", cwd.characters(), argv[1]); path_builder.appendff("{}/{}", cwd, argv[1]);
} }
} else if (argc == 3) { } else if (argc == 3) {
directory_stack.append(cwd.characters()); directory_stack.append(cwd.characters());
@ -721,7 +721,7 @@ int Shell::builtin_pushd(int argc, const char** argv)
if (arg[0] == '/') { if (arg[0] == '/') {
path_builder.append(arg); path_builder.append(arg);
} else } else
path_builder.appendf("%s/%s", cwd.characters(), arg); path_builder.appendff("{}/{}", cwd, arg);
} }
if (!strcmp(arg, "-n")) if (!strcmp(arg, "-n"))

View file

@ -242,7 +242,7 @@ void Formatter::visit(const AST::CloseFdRedirection* node)
test_and_update_output_cursor(node); test_and_update_output_cursor(node);
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
current_builder().appendf("%d>&-", node->fd()); current_builder().appendff("{}>&-", node->fd());
visited(node); visited(node);
} }
@ -307,7 +307,7 @@ void Formatter::visit(const AST::Fd2FdRedirection* node)
test_and_update_output_cursor(node); test_and_update_output_cursor(node);
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
current_builder().appendf("%d>&%d", node->source_fd(), node->dest_fd()); current_builder().appendff("{}>&{}", node->source_fd(), node->dest_fd());
if (m_hit_node == node) if (m_hit_node == node)
++m_output_cursor; ++m_output_cursor;
visited(node); visited(node);
@ -673,7 +673,7 @@ void Formatter::visit(const AST::ReadRedirection* node)
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
if (node->fd() != 0) if (node->fd() != 0)
current_builder().appendf(" %d<", node->fd()); current_builder().appendff(" {}<", node->fd());
else else
current_builder().append(" <"); current_builder().append(" <");
NodeVisitor::visit(node); NodeVisitor::visit(node);
@ -687,7 +687,7 @@ void Formatter::visit(const AST::ReadWriteRedirection* node)
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
if (node->fd() != 0) if (node->fd() != 0)
current_builder().appendf(" %d<>", node->fd()); current_builder().appendff(" {}<>", node->fd());
else else
current_builder().append(" <>"); current_builder().append(" <>");
NodeVisitor::visit(node); NodeVisitor::visit(node);
@ -878,7 +878,7 @@ void Formatter::visit(const AST::WriteAppendRedirection* node)
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
if (node->fd() != 1) if (node->fd() != 1)
current_builder().appendf(" %d>>", node->fd()); current_builder().appendff(" {}>>", node->fd());
else else
current_builder().append(" >>"); current_builder().append(" >>");
NodeVisitor::visit(node); NodeVisitor::visit(node);
@ -892,7 +892,7 @@ void Formatter::visit(const AST::WriteRedirection* node)
TemporaryChange<const AST::Node*> parent { m_parent_node, node }; TemporaryChange<const AST::Node*> parent { m_parent_node, node };
if (node->fd() != 1) if (node->fd() != 1)
current_builder().appendf(" %d>", node->fd()); current_builder().appendff(" {}>", node->fd());
else else
current_builder().append(" >"); current_builder().append(" >");
NodeVisitor::visit(node); NodeVisitor::visit(node);

View file

@ -77,8 +77,8 @@ String Shell::prompt() const
return "# "; return "# ";
StringBuilder builder; StringBuilder builder;
builder.appendf("\033]0;%s@%s:%s\007", username.characters(), hostname, cwd.characters()); builder.appendff("\033]0;{}@{}:{}\007", username, hostname, cwd);
builder.appendf("\033[31;1m%s\033[0m@\033[37;1m%s\033[0m:\033[32;1m%s\033[0m$> ", username.characters(), hostname, cwd.characters()); builder.appendff("\033[31;1m{}\033[0m@\033[37;1m{}\033[0m:\033[32;1m{}\033[0m$> ", username, hostname, cwd);
return builder.to_string(); return builder.to_string();
} }