fix print type

This commit is contained in:
Joseph Aquino 2025-12-25 19:32:34 -05:00
parent fbf703b35c
commit ea552af646
2 changed files with 4 additions and 6 deletions

View File

@ -15,7 +15,6 @@ int main()
while (!exit) while (!exit)
{ {
std::string input; std::string input;
std::cout << std::unitbuf;
std::cout << "$ "; std::cout << "$ ";
std::getline(std::cin, input); std::getline(std::cin, input);
std::optional<std::string> result; std::optional<std::string> result;

View File

@ -61,22 +61,21 @@ namespace sh
void printType(const std::string& input) void printType(const std::string& input)
{ {
const std::string_view command {input.substr(0, input.find(' '))}; if (commandMap.contains(input))
if (commandMap.contains(command))
{ {
std::cout << command; std::cout << input;
std::cout << " is a shell builtin\n"; std::cout << " is a shell builtin\n";
return; return;
} }
if (const auto fullPath {isExec(input)}) if (const auto fullPath {isExec(input)})
{ {
std::cout << command; std::cout << input;
std::cout << " is " << fullPath.value() << "\n"; std::cout << " is " << fullPath.value() << "\n";
return; return;
} }
std::cout << command; std::cout << input;
std::cout << ": not found\n"; std::cout << ": not found\n";
} }
} }