blob: cee0290b358dc5918a3fe32309ffc1d9a7ccafc0 (
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
71
72
73
74
75
76
77
|
# function zfget {
# Get files from remote server. Options:
# -c cat: dump files to stdout.
# alias zfcat="zfget -c"
# zfpage() { zfget -c "$@" | eval $PAGER }
# are sensible things to do, but aren't done for you. Note the
# second doesn't work on all OS's.
# -G don't to remote globbing, else do
# -t update the local file times to the same time as the remote.
# Currently this only works if you have the `perl' command,
# and that perl is version 5 with the standard library.
# See the function zfrtime for more gory details. This has
# no effect with the -c option.
#
# If the connection is not currently open, try to open it with the current
# parameters (set by a previous zfopen or zfparams), then close it after
# use. The file is put in the current directory (i.e. using the basename
# of the remote file only); for more control, use zfgcp.
emulate -L zsh
local loc rem optlist opt nglob remlist time cat
integer stat do_close
while [[ $1 == -* ]]; do
if [[ $1 == - || $1 == -- ]]; then
shift;
break;
fi
optlist=${1#-}
for (( i = 1; i <= $#optlist; i++)); do
opt=$optlist[$i]
case $opt in
G) nglob=1
;;
t) time=1
;;
c) cat=1
;;
*) print option $opt not recognised >&2
;;
esac
done
shift
done
zfautocheck
for remlist in $*; do
# zfcd directory hack to put the front back to ~
if [[ $remlist == $HOME || $remlist == $HOME/* ]]; then
remlist="~${remlist#$HOME}"
fi
if [[ $nglob != 1 ]]; then
zfrglob remlist
fi
if (( $#remlist )); then
for rem in $remlist; do
if [[ -n $cat ]]; then
zftp get $rem
stat=$?
else
loc=${rem:t}
if zftp get $rem >$loc; then
[[ $time = 1 ]] && zfrtime $rem $loc
else
stat=1
fi
fi
done
fi
done
(( $do_close )) && zfclose
return $stat
# }
|