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

View file

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

View file

@ -77,8 +77,8 @@ String Shell::prompt() const
return "# ";
StringBuilder builder;
builder.appendf("\033]0;%s@%s:%s\007", username.characters(), hostname, cwd.characters());
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]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_string();
}