Treating symlinks consistently in `pathlib.Path.glob()`

Some notes on shell globbing

IIUC shells always follow symlinks when expanding non-recursive patterns, like foo/bar or package/*.py.

Support for ** and *** wildcards is enabled via a globstar shell option in some shells. Support is as follows:

** ***
sh, bash 3 non-recursive non-recursive
bash 4.0 w/ globstar follows links non-recursive
bash 4.3 w/ globstar doesn’t follow non-recursive
zsh doesn’t follow follows links
tcsh w/ globstar doesn’t follow follows links
fish follows links? non-recursive?

pathlib’s default behaviour is similar to bash 4.3 w/ globstar, whereas glob.glob() is like bash 4.0.

1 Like