diff options
| author | Dan Engelbrecht <[email protected]> | 2025-01-23 12:49:46 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2025-01-23 12:49:46 +0100 |
| commit | 5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c (patch) | |
| tree | cb64f2d93a9f5e8b0e1529ab0dc3371602688a4f /src/zen/cmds/workspaces_cmd.cpp | |
| parent | changelog (diff) | |
| parent | handle special backslash followed by quote for paths (#279) (diff) | |
| download | archived-zen-5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c.tar.xz archived-zen-5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c.zip | |
Merge remote-tracking branch 'origin/main' into de/zen-service-command
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); + } } } |