mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:07:35 +00:00
Shell: Disable SH_DEBUG by default and tidy up command timing logging
This commit is contained in:
parent
f38cfb3562
commit
41716aebde
1 changed files with 13 additions and 11 deletions
|
@ -46,7 +46,7 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SH_DEBUG
|
//#define SH_DEBUG
|
||||||
|
|
||||||
GlobalState g;
|
GlobalState g;
|
||||||
static LineEditor editor;
|
static LineEditor editor;
|
||||||
|
@ -301,8 +301,7 @@ static int sh_pushd(int argc, char** argv)
|
||||||
g.directory_stack.append(g.cwd.characters());
|
g.directory_stack.append(g.cwd.characters());
|
||||||
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", g.cwd.characters(), argv[1]);
|
path_builder.appendf("%s/%s", g.cwd.characters(), argv[1]);
|
||||||
}
|
}
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
|
@ -313,8 +312,7 @@ static int sh_pushd(int argc, char** argv)
|
||||||
if (arg[0] != '-') {
|
if (arg[0] != '-') {
|
||||||
if (arg[0] == '/') {
|
if (arg[0] == '/') {
|
||||||
path_builder.append(arg);
|
path_builder.append(arg);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
path_builder.appendf("%s/%s", g.cwd.characters(), arg);
|
path_builder.appendf("%s/%s", g.cwd.characters(), arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,17 +466,21 @@ private:
|
||||||
Vector<int, 32> m_fds;
|
Vector<int, 32> m_fds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CommandTimer {
|
class CommandTimer {
|
||||||
CommandTimer()
|
public:
|
||||||
|
explicit CommandTimer(const String& command)
|
||||||
|
: m_command(command)
|
||||||
{
|
{
|
||||||
timer.start();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
~CommandTimer()
|
~CommandTimer()
|
||||||
{
|
{
|
||||||
dbgprintf("sh: command finished in %d ms\n", timer.elapsed());
|
dbg() << "Command \"" << m_command << "\" finished in " << m_timer.elapsed() << " ms";
|
||||||
}
|
}
|
||||||
|
|
||||||
CElapsedTimer timer;
|
private:
|
||||||
|
CElapsedTimer m_timer;
|
||||||
|
String m_command;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool is_glob(const StringView& s)
|
static bool is_glob(const StringView& s)
|
||||||
|
@ -733,7 +735,7 @@ static int run_command(const String& cmd)
|
||||||
|
|
||||||
Vector<SpawnedProcess> children;
|
Vector<SpawnedProcess> children;
|
||||||
|
|
||||||
CommandTimer timer;
|
CommandTimer timer(cmd);
|
||||||
|
|
||||||
for (int i = 0; i < command.subcommands.size(); ++i) {
|
for (int i = 0; i < command.subcommands.size(); ++i) {
|
||||||
auto& subcommand = command.subcommands[i];
|
auto& subcommand = command.subcommands[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue