diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/workspaces_cmd.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp index 2c8fe43f6..05d3c573f 100644 --- a/src/zen/cmds/workspaces_cmd.cpp +++ b/src/zen/cmds/workspaces_cmd.cpp @@ -22,11 +22,23 @@ namespace zen { namespace { static void RemoveTrailingPathSeparator(std::filesystem::path& Path) { - std::u8string PathString = Path.u8string(); - if (PathString.ends_with(std::filesystem::path::preferred_separator)) + if (!Path.empty()) { - PathString.pop_back(); - Path = std::filesystem::path(PathString); + std::u8string PathString = Path.u8string(); + if (PathString.ends_with(std::filesystem::path::preferred_separator)) + { + PathString.pop_back(); + Path = std::filesystem::path(PathString); + } + // Special case if user gives a path with quotes and includes a backslash at the end: + // ="path\" cxxopts strips the leading quote only but not the trailing. + // As we expect paths here and we don't want trailing slashes we strip away the quote + // manually if the string does not start with a quote UE-231677 + else if (PathString[0] != '\"' && PathString[PathString.length() - 1] == '\"') + { + PathString.pop_back(); + Path = std::filesystem::path(PathString); + } } } |