Fix "." and ".." paths in cd completions

Previously if a directory called "a" was in $CDPATH, `cd ./a<TAB>` would
complete from there even if it was invalid.
This commit is contained in:
Fabian Homborg 2016-04-08 15:03:49 +02:00
parent 8eb9dac4bc
commit d7c690b416

View File

@ -1,7 +1,7 @@
function __fish_complete_cd -d "Completions for the cd command"
set -l token (commandline -ct)
# Absolute path - no descriptions and no CDPATH
if string match -q '/*' -- $token
# Absolute path or explicitly from the current directory - no descriptions and no CDPATH
if string match -qr '^\.?\.?/.*' -- $token
for d in $token*/
# Check if it's accessible - the glob only matches directories
[ -x $d ]; and printf "%s\n" $d