New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str expand doesn't like backslashes for path separators #9838
Comments
I'm sorry, it's actually not a bug. bracoxide ignores what's came after the backslash. Sorry, I forgot to add that to the examples. Take a look at this example, (I'm also updating the examples). 'A{B\,,C}' | str expand bracoxide (I implemented this feature intentionally) walks through the chars, sees there is a ╭───┬─────╮
│ 0 │ AB, │
│ 1 │ AC │
╰───┴─────╯ another example: 'A{B\\,C}' | str expand produces: ╭───┬─────╮
│ 0 │ AB\ │
│ 1 │ AC │
╰───┴─────╯ So, to solve the problem, we left with (make the backslashes double algorithm): 'crates' | path join 'nu-utils' 'src' 'sample_config' 'default_{config,env}.nu' | str replace '\\' '\\\\'| str expand I don't have an idea, should bracoxide crate just handle escaping braces ( |
hmmm, it seems that |
I think I might change how bracoxide handles the escaping. Let's say the piped data is |
As for the, windows side part, should not be a problem unless it is: See the |
Windows is a mess with the stupid backslash. It always has been. I think this is where nushell handles this type of escaping. I almost added some more the other day. |
I agree, that's why I don't use Windows. 😅 It's still a pain in the back to set up a fully functional development environment on Windows. That's exactly why I switched to Linux 6+ years ago. The stupid Windows. Makes everything difficult. I think the best approach to this would be Cause if I change how the bracoxide handles the escaping. It's still a mess on Windows if the folder starts with 'a', 'b', 'e', 'f', 'n', 'r', 't', 'u'. Then the user should replace I can create a PR for |
That would be great! Thanks for the help! |
Hi, I made changes to I may add the |
I am suspicious of the claim that the solution is to make changes to one |
I can create a flag to str expand, such as So below command ['C:', '\', 'Users', 'viking', "{spam,welcome}.txt"] | path join --escape | str expand turns into ['C:', '\', 'Users', 'viking', "{spam,welcome}.txt"] | path join | str expand --path Which is fine for me, I'll do exactly the same operation, replace all single backslashes with the double backslashes.
bracoxide crate is open for contributions. I had 2 ideas for skipping:
I couldn't find any more ideas than these. My honest thought clarifies that the first option which is using backslashes by far the best option. Just in case, I'll pretty soon create a PR for |
From my perspective, I'm fine with either I'm also fine with deferring where to put the command to any core-team member, like @sholderbach, who fervently believes it needs to be one or the other. Either is fine as long as it fixes the problem without having to do str replace manually. |
**Related Issue: #9838** Adds an **example**, how bracoxide/str-expand handles the escaping char `\`.
Related issues: #9838 Changes: - added `--path` flag, for ease of use if the piped data is Path (replaces all backslashes with double backslashes)
Describe the bug
@atahabaki I think we just found a bug? in
str expand
. Would you mind taking a look at it?On Windows, the path separator is
\
. If we do this:all looks good until we add
str expand
, which gives us this:What I expect is the same output as this.
Thoughts? Maybe this is the correct behavior? I'm not sure. It makes dealing with Windows paths difficult.
How to reproduce
see above
Expected behavior
see above
Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: