blob: 677b85f4b733437f559cd1ae44af0ffec1a03a50 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# function zfrglob {
# Do the remote globbing for zfput, etc.
# We have two choices:
# (1) Get the entire file list and match it one by one
# locally against the pattern.
# Causes problems if we are globbing directories (rare, presumably).
# But: we can cache the current directory, which
# we need for completion anyway. Works on any OS if you
# stick with a single directory. This is the default.
# (2) Use remote globbing, i.e. pass it to ls at the site.
# Faster, but only works with UNIX, and only basic globbing.
# We do this if the remote-glob style (or $zfrglob for
# backward compatibility) is set.
# There is only one argument, the variable containing the
# pattern to be globbed. We set this back to an array containing
# all the matches.
emulate -L zsh
setopt extendedglob
local pat dir nondir files i zfrglob
zstyle -t "$curcontext" remote-glob && zfrglob=1
eval pat=\$$1
# Check if we really need to do anything. Look for standard
# globbing characters, and if we are
# using zsh for the actual pattern matching also look for
# extendedglob characters.
if [[ $pat != *[][*?]* &&
( -n $zfrglob || $pat != *[(|)#^]* ) ]]; then
return 0
fi
if [[ $zfrglob != '' ]]; then
() {
zftp ls "$pat" >|$1 2>/dev/null
eval "$1=(\$(<\$1))"
} =(<<<'temporary file')
else
if [[ $ZFTP_SYSTEM = UNIX* && $pat = */* ]]; then
# not the current directory and we know how to handle paths
if [[ $pat = ?*/* ]]; then
# careful not to remove too many slashes
dir=${pat%/*}
else
dir=/
fi
nondir=${pat##*/}
() {
zftp ls "$dir" 2>/dev/null >|$1
files=($(<$1))
} =(<<<'temporary file')
files=(${files:t})
else
# we just have to do an ls and hope that's right
local fcache_name
zffcache
nondir=$pat
files=(${(P)fcache_name})
fi
# now we want to see which of the $files match $nondir:
# ${...:/foo} deletes occurrences of foo matching a complete word,
# while the ^ inverts the sense so that anything not matching the
# pattern in $nondir is excluded.
eval "$1=(\${files:/^\${~nondir}})"
fi
# }
|