-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix #8225 os.isHidden was buggy on posix #8315
Conversation
688fc2d
to
47f6193
Compare
With regards to the "this should purely be a string operation", this makes the behavior of the function subtly different across Linux and Windows. It means that on Windows, the function can only be called on existing files, while on Linux it can be called on all possible file names. |
well I had suggested #8225 (comment) which would've mostly avoided that issue via a cross platform
but @dom96 suggested not to:
That just reflects OS differences; can't completely hide differences here |
lib/pure/os.nim
Outdated
## NOTE: on OSX, in addition to the "dotfile" behaviour, existing paths with the | ||
## "Invisible" attribute are hidden in Finder, although not in ls | ||
## NOTE: the behavior of certain corner cases (see examples) ".foo/" is | ||
## unspecified, subject to change (can be avoided using `normalizePath`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When writing docs, please check what they look like with nim doc
. Currently this is all going to be one huge paragraph, and therefore hard to read. Add empty ##
to separate this and use bold instead of ALLCAPS to emphasise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on that note is there a canonical "perfect" reference function we can use as a template? (that was one of my goals with #8271 btw)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have a "perfect" function to link to, but here is how these should be structured:
proc foo() =
## Performs the foo operation.
##
## The foo operation is a very important operation
## in computer science. It solves all our problems.
##
## **Warning:** Calling ``foo`` when the ``blarg``
## was activated previously may cause the world to
## end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen both these:
`foo`
vs
``foo``
and both work (and foo
is simpler and more familiar for ppl familiar w markdown); ok to use single ticks ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, they aren't the same in RST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/pure/os.nim
Outdated
doAssert(not "".isHidden) | ||
# TODO: decide on these: | ||
# doAssert ".foo/".isHidden # un-specified | ||
# doAssert ".foo/.".isHidden # un-specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't abuse runnableExamples
for a test suite. The docs should show one or two examples, not an exhaustive list of checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, kept the minimum sufficient set to clarify semantics
@dom96 PTAL |
lib/pure/os.nim
Outdated
## On posix: a hidden path starts with ``.`` (see examples). | ||
## | ||
## On OSX, in addition to the "dotfile" behaviour, existing paths with the | ||
## "Invisible" attribute are hidden in Finder, although not in ``ls``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you discussing Finder's behaviour here? This is confusing because it implies that this function follows the Finder behaviour but I don't think that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed that comment (which was just to say there's a difference bw Finder's hidden vs ls's hidden, even though this function deals with ls's hidden)
lib/pure/os.nim
Outdated
result = len(fileName) >= 2 and fileName[0] == '.' and fileName != ".." | ||
|
||
when isMainModule: | ||
doAssert ".foo.ext".isHidden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put these into tos
please: https://github.com/nim-lang/Nim/blob/devel/tests/stdlib/tos.nim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done (also moved absolutePath
tests there)
4679ec2
to
2b5e80c
Compare
@timotheecour This is still failing tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to just be an indentation error that's making tests fail (though now there will be some conflicts to fix up since it's been a bit). L178 of tests/stdlib/tos.nim
this is waiting on #9116 which I need in implementation |
350c91c
to
3a0ac8d
Compare
PTAL, all comments addressed |
1766317
to
89f7f95
Compare
89f7f95
to
c73ca78
Compare
* fix nim-lang#8225 isHidden was broken on posix * scope rest of tos.nim under blocks to avoid variable scope bugs
* fix nim-lang#8225 isHidden was broken on posix * scope rest of tos.nim under blocks to avoid variable scope bugs
/cc @dom96
fixes #8225
fixed bugs on posix:
isHidden(".git")
now returns true.ab.txt
was considered not hidden (even if it existed!) because of the weird conditionfileName[3] != '.'
EDIT: use the new
lastPathPart
proc so thatisHidden(".git/")
now returns true as well