Fix wildcard expansion in directories without read permissions

When performing wildcard expansion with a literal path segment,
instead of enumerating the files in the directory, simply apply the
path segment as if we found the directory and continue on. This
enables us to expand strings that contain unreadable directory
components (common with $HOME) and also improves performance, since
we don't waste time enumerating directories unnecessarily. Adds
a test too.

Fixes #2099
This commit is contained in:
ridiculousfish
2015-06-20 12:26:03 -07:00
parent 8db162e048
commit 4621e763b6
3 changed files with 53 additions and 37 deletions

View File

@@ -23,3 +23,15 @@ switch $smurf
case "?????"
echo Test 3 pass
end
# Verify that we can do wildcard expansion when we
# don't have read access to some path components
# See #2099
set -l where /tmp/fish_wildcard_permissions_test/noaccess/yesaccess
mkdir -p $where
chmod 300 (dirname $where) # no read permissions
mkdir -p $where
touch $where/alpha.txt $where/beta.txt $where/delta.txt
echo $where/*
chmod 700 (dirname $where) # so we can delete it
rm -rf /tmp/fish_wildcard_permissions_test

View File

@@ -1,3 +1,4 @@
Test 1 pass
Test 2 pass
Test 3 pass
/tmp/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt