Fix string view created from a temporary string

This is clearly a case where rust style lifetime analysis would
have been nice, hopefully it comes with GSL lifetime extensions...

Fixes #680
This commit is contained in:
Maxime Coste 2016-05-24 22:36:20 +01:00
parent fa35330b42
commit 5cab2078f8

View File

@ -1871,8 +1871,7 @@ const CommandDesc change_working_directory_cmd = {
}},
[](const ParametersParser& parser, Context&, const ShellContext&)
{
StringView target = parser.positional_count() == 1 ? parser[0] : "~";
StringView target = parser.positional_count() == 1 ? StringView{parser[0]} : "~";
if (chdir(parse_filename(target).c_str()) != 0)
throw runtime_error(format("cannot change to directory '{}'", target));
for (auto& buffer : BufferManager::instance())