aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-01-22 15:27:09 +0100
committerGitHub Enterprise <[email protected]>2025-01-22 15:27:09 +0100
commitdd1c78c66de731306c06e8cfefcdb778d46bfcce (patch)
tree04a1a7c178c43666de7f7f9b472ed156f6373da5 /src
parentAdd multithreading directory scanning in core/filesystem (#277) (diff)
downloadzen-dd1c78c66de731306c06e8cfefcdb778d46bfcce.tar.xz
zen-dd1c78c66de731306c06e8cfefcdb778d46bfcce.zip
handle special backslash followed by quote for paths (#279)
Diffstat (limited to 'src')
-rw-r--r--src/zen/cmds/workspaces_cmd.cpp20
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);
+ }
}
}