diff options
| author | Stefan Boberg <[email protected]> | 2025-01-29 15:08:03 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-01-29 15:08:03 +0100 |
| commit | e64c8727ecb073ca03e2c7d4b3972c375c1b6315 (patch) | |
| tree | 04a1a7c178c43666de7f7f9b472ed156f6373da5 /src/zen/cmds/workspaces_cmd.cpp | |
| parent | Merge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zen (diff) | |
| parent | handle special backslash followed by quote for paths (#279) (diff) | |
| download | archived-zen-sb/cleanup-main.tar.xz archived-zen-sb/cleanup-main.zip | |
Merge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zensb/cleanup-main
Diffstat (limited to 'src/zen/cmds/workspaces_cmd.cpp')
| -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); + } } } |