File tree Expand file tree Collapse file tree 3 files changed +4
-3
lines changed
Expand file tree Collapse file tree 3 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ CommandFactory::CommandFactory() {
44 commands[" exit" ] = std::make_unique<ExitCommand>();
55 commands[" echo" ] = std::make_unique<EchoCommand>();
66 commands[" type" ] = std::make_unique<TypeCommand>();
7+ commands[" pwd" ] = std::make_unique<PwdCommand>();
78}
89
910Command* CommandFactory::get (const std::string& name) {
Original file line number Diff line number Diff line change 66#include " exit_command.h"
77#include " echo_command.h"
88#include " type_command.h"
9+ #include " pwd_command.h"
910
1011class CommandFactory {
1112 std::map<std::string, std::unique_ptr<Command>> commands;
Original file line number Diff line number Diff line change 33#include < unistd.h>
44
55void PwdCommand::execute (const std::string& args) {
6- char *cwd;
7- getcwd (cwd, sizeof (cwd));
8- if (cwd != nullptr ) {
6+ char cwd[1024 ];
7+ if (getcwd (cwd, sizeof (cwd)) != nullptr ) {
98 std::cout << cwd << std::endl;
109 } else {
1110 std::cerr << " Error getting current working directory" << std::endl;
You can’t perform that action at this time.
0 commit comments