GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — enable support of folders and files with colon in name on Unix by SteveL-MSFT · Pull Request #4959 · PowerShell/PowerShell Conversation
Member
allow colons if it shows up after a path separator fix #4889
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Steve Lee (SteveL-MSFT)
requested review from
Aditya Patwardhan (adityapatwardhan) and
Andrew (anmenaga)
Steve Lee (SteveL-MSFT)
requested a review
from Bruce Payette (BrucePay)
as a code owner
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is inefficient to do unconditionally for an uncommon case, but it also doesn't fully fix the problem. Is it not possible to check if it looks like a drive, and if not, then it moist be a file? There are downsides to that approach though, so if it was rejected, I think it's worth noting why in the code.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with the current code is that it always checks for the colon you see above and if it's there, it assumes it's a drive. What I'm doing here is what you are saying. If the colon is after a path separator, it doesn't look like a drive. If you mean to see if the left of the colon is a drive, wouldn't that be a bigger perf hit? I could certainly only look for the separator only if there is a colon.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this change this still won't work: 1+1 > foo:bar.txt instead you have to do: 1+1 > ./foo:bar.txt Which seems fine to me
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At a minimum, yes, only look for the separator if there is a colon. But the inconsistency of requiring a separator only if there is a colon - that seems silly and not easy to discover. I guess I was suggesting to assume it's a drive (maybe not if there is a separator) because we're doing that already, and if it's not a drive, then don't error out, treat it as a filesystem path. Of course this does introduce an ambiguity: Set-Content -Path env:abc -Value 123 This sets the environment variable, not the file content. In cases like this, you'd have to use a separator. This example might seem not interesting, but something like this is more problematic: Set-Content -Path "${prefix}:${suffix}" -Value 123
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I like having the distinction between a drive and a file with the separator.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Steve Lee (SteveL-MSFT)
force-pushed
the
colon-path
branch
from
92b947a to
6394373
Compare
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Steve Lee (SteveL-MSFT)
force-pushed
the
colon-path
branch
from
6394373 to
5a62062
Compare
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Mike Richmond (mirichmo)
suggested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the documentation this does not look correct to me. It searches the string starting from the beginning though index count of characters for the matching separator. "C:\something.txt" Will always fail because the separator never matches the first character of the string ("C"). I think you might need: separator = path.IndexOf(StringLiterals.AlternatePathSeparator, index, 1); This checks the character immediately after the index. But if you are going to do that, you might as well directly test index+1.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Steve Lee (SteveL-MSFT)
force-pushed
the
colon-path
branch
from
3a062d8 to
000a29c
Compare
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Mike Richmond (mirichmo)
approved these changes
Thatgfsj (Thatgfsj)
pushed a commit
to Thatgfsj-contribs/PowerShell
that referenced
this pull request
…Shell#4959) * [feature] support folders and files with colon in name * [feature] only check separator in relation to colon if a colon is found * [feature] added comment to clarify algorithm * added more tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers2 more reviewersUh oh!
There was an error while loading. Please reload this page. AssigneesLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Linux: cd and find commands fail when a colon is in the directory or file nameUh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |