glob icon indicating copy to clipboard operation
glob copied to clipboard

Add an option to not follow symlinks

Open aplanas opened this issue 7 years ago • 6 comments

Add follow_links option in MatchOptions struct to signalize when to follow symlinks when the directory is traversed. The default value is false.

aplanas avatar Sep 20 '17 20:09 aplanas

Initial proposal for issue https://github.com/rust-lang-nursery/glob/issues/62

aplanas avatar Sep 20 '17 20:09 aplanas

I'd be against having this in MatchOptions. Glob matching should always be a comparison against strings. No file system should be harmed in the process :)

As far as I can tell, the symlink problem arises from the helper methods that walk the directory structure in some way. They should have their own separate option system instead.

piegamesde avatar Nov 12 '21 11:11 piegamesde

@piegamesde Oh that is a good argument. I forgot this PR actually, but where do you think that the "follow_symlink" flag should live? As a boolean parameter is some function?

aplanas avatar Nov 12 '21 12:11 aplanas

@piegamesde I don't really understand your argument against this option. If I traverse a file tree and want to get, or check, the symlinks themselves then I cannot use glob without the follow_symlink option. I would appreciate to have this in included. To not change the default behavior the default value of this option can be true. @aplanas Please can you consider to merge this with follow_symlink=true as the default value?

brmmm3 avatar Apr 15 '23 05:04 brmmm3

@brmmm3 I'm not against having a follow symlinks option. I am against putting it there, in the MatchOptions. The reason is that MatchOptions is also used by functions like Pattern::matches_with, which do not and should not involve any file system operations. Having a file system related option in that struct would be confusing and unfit.

piegamesde avatar Apr 15 '23 09:04 piegamesde

While @piegamesde's argument is valid, I also think this is the simplest way. Maybe we can add a note describing this option doesn't make sense in some context?

JohnTitor avatar Apr 22 '23 03:04 JohnTitor