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

Broken symlink causes wildcard matching to fail #1240

Closed
muesli opened this issue Feb 13, 2021 · 3 comments · Fixed by #1567
Closed

Broken symlink causes wildcard matching to fail #1240

muesli opened this issue Feb 13, 2021 · 3 comments · Fixed by #1567
Labels

Comments

@muesli
Copy link
Contributor

muesli commented Feb 13, 2021

I have a directory with two files in it:

file1
file2

file1 is a symlink pointing to a file that doesn't exist anymore.
file2 is a regular file.

ls file* now fails: Exception: wildcard has no match

Fixing the symlink of file1 resolves the issue.

@hanche
Copy link
Contributor

hanche commented Feb 13, 2021

As @krader1961 has mentioned in chat, this issue and #1236 are probably related.

@krader1961
Copy link
Contributor

I just tried an experiment with several files and directories, including a dead symlink, in a test dir. Running put * does not throw an error. It simply stops enumerating files when it reaches the dead symlink. Note that put d* does throw an exception. Which suggests there might be a second problem with wildcard expansion; or at least the need to unify some code for consistent behavior.

@clonejo
Copy link

clonejo commented Jun 12, 2022

One example where this bug hits hard is a git-annex repo where not all files are locally available. Those files are then represented as dangling symlinks. Normally you could do move operations on those symlinks just fine, but not having wildcards available makes it a hassle.

krader1961 added a commit to krader1961/elvish that referenced this issue Jun 27, 2022
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.

The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.

Fixes elves#1240
krader1961 added a commit to krader1961/elvish that referenced this issue Jun 27, 2022
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.

The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.

Fixes elves#1240
krader1961 added a commit to krader1961/elvish that referenced this issue Jun 29, 2022
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.

The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.

Fixes elves#1240
xiaq pushed a commit that referenced this issue Aug 28, 2022
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.

The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.

Fixes #1240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants