fix print type
This commit is contained in:
parent
fbf703b35c
commit
ea552af646
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue