glob
glob copied to clipboard
Add an option to not follow symlinks
Add follow_links
option in MatchOptions
struct to signalize
when to follow symlinks when the directory is traversed. The
default value is false
.
Initial proposal for issue https://github.com/rust-lang-nursery/glob/issues/62
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 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?
@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 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.
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?