1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-02 17:01:19 +02:00
zsh/Functions/Zftp/zffcache
1999-09-10 13:58:19 +00:00

25 lines
693 B
Plaintext

# Generate an array name for storing the cache for the current session,
# storing it in fcache_name, then generate the cache for the current
# directory, or with argument -d clear the cache.
fcache_name=$zfconfig[fcache_$ZFTP_SESSION]
if [[ -z $fcache_name ]]; then
local vals
vals=(${(v)zfconfig[(I)fcache_*]##zftp_fcache_})
integer i
while [[ -n ${vals[(r)zftp_fcache_$i]} ]]; do
(( i++ ))
done
fcache_name=zftp_fcache_$i
zfconfig[fcache_$ZFTP_SESSION]=$fcache_name
fi
if [[ $1 = -d ]]; then
unset $fcache_name
elif (( ${(P)#fcache_name} == 0 )); then
local tmpf=${TMPPREFIX}zffcache$$
zftp ls >$tmpf
eval "$fcache_name=(\${(f)\"\$(<\$tmpf)\"})"
rm -f $tmpf
fi