Fix first == npos bug.
This commit is contained in:
@@ -18,6 +18,9 @@ void Function::register_extented(BEd &ctx) {
|
||||
auto path = std::get<std::string>(arg_);
|
||||
const auto first = path.find_first_not_of(" \t");
|
||||
const auto last = path.find_last_not_of(" \t");
|
||||
if (first == std::string::npos)
|
||||
path.clear();
|
||||
else
|
||||
path = path.substr(first, last - first + 1);
|
||||
if (path.empty())
|
||||
path = getenv("HOME");
|
||||
@@ -28,7 +31,6 @@ void Function::register_extented(BEd &ctx) {
|
||||
if (home)
|
||||
path = std::string(home) + path.substr(1);
|
||||
}
|
||||
if (first != std::string::npos)
|
||||
if (chdir(path.c_str()) == -1)
|
||||
throw ed_error("Can't change directory.");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user