Skip to content
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

[critical] walkGlob doesn't work with symlinks in pattern; unlike ls, os.walkDir etc #36

Closed
timotheecour opened this issue Jan 16, 2020 · 0 comments · Fixed by #38
Closed
Labels
help wanted Extra attention is needed type: bug Something isn't working as intended or expected.

Comments

@timotheecour
Copy link
Collaborator

/cc @citycide

say in /Users/timothee/temp/d18_D20200115T203454/ we have symlinks:

ls
total 0
drwxr-xr-x 4 timothee 128 Jan 15 20:43 bar1/
lrwxr-xr-x 1 timothee   4 Jan 15 20:43 bar2 -> bar1/
-rw-r--r-- 1 timothee   0 Jan 15 20:40 foo1.foo2.foo3.log
-rw-r--r-- 1 timothee   0 Jan 15 20:39 foo1.foo2.log
-rw-r--r-- 1 timothee   0 Jan 15 20:35 foo1.log
  import pkg/glob
  import std/os
  proc main()=
    # do `ln -s bar1 bar2` inside the dir
    let pattern2 = "/Users/timothee/temp/d18_D20200115T203454/bar2/*.log"
    echo "walkGlob:"
    for file1 in walkGlob(pattern2):
      echo (file1: file1)
    echo "walkFiles:"
    for file2 in walkFiles(pattern2):
      echo (file2: file2)

  main()

this produces:

walkGlob:
walkFiles:
(file2: "/Users/timothee/temp/d18_D20200115T203454/bar2/foo1.foo2.log")
(file2: "/Users/timothee/temp/d18_D20200115T203454/bar2/foo1.log")

note

this often occurs in practice, eg on OSX /tmp is a symlink to /private/tmp/:

realpath /tmp
/private/tmp

and walkGlob("/tmp/*.log") doesnt' return anything !

note

the returns files should keep the original name (eg /tmp/, not /private/tmp/), not the realpath names; as is done with all the tools including os.walkDir

@timotheecour timotheecour changed the title [critical] walkGlob doesn't work with symlinks; unlike ls, os.walkDir etc [critical] walkGlob doesn't work with symlinks in pattern; unlike ls, os.walkDir etc Jan 16, 2020
@haltcase haltcase added help wanted Extra attention is needed type: bug Something isn't working as intended or expected. labels Jan 16, 2020
timotheecour added a commit to timotheecour/glob that referenced this issue Jan 17, 2020
timotheecour added a commit to timotheecour/glob that referenced this issue Jan 18, 2020
timotheecour added a commit to timotheecour/glob that referenced this issue Jan 19, 2020
haltcase pushed a commit that referenced this issue Jan 20, 2020
* fix #36; correctness wrt symlinks

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type: bug Something isn't working as intended or expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants