Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cd_command.h"
- #include "../shell/system_functions.h"
- #include <utility>
- #include <iostream>
- ast::cd_command::cd_command(std::vector<unevaluated_argument> &arguments): command(arguments) {}
- int ast::cd_command::execute(ast::scope &scope) {
- std::vector<char*> params;
- for (auto& arg_pattern : arguments) {
- auto evaluated_argument = ast::argument(arg_pattern.evaluate(scope));
- auto evaluated_values = evaluated_argument.get_value();
- params.push_back(const_cast<char*>(evaluated_values.c_str()));
- }
- if (params.size() != 1) {
- perror("Wrong number of command arguments. There should be only one argument.");
- return -1;
- }
- // std::cout << params.at(0) << std::endl;
- scope.get_system_functions()->change_directory(params.at(0));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement