summaryrefslogtreecommitdiff
path: root/Functions/Zftp/zfget
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:45 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:45 +0000
commite8eb43fc308acb3f1a8ebada7633c097e5050e46 (patch)
tree2df36ef3c7709c7d4d3b7bdcb5761f98649859bf /Functions/Zftp/zfget
parente74702b467171dbdafb56dfe354794a212e020d9 (diff)
downloadzsh-e8eb43fc308acb3f1a8ebada7633c097e5050e46.tar.gz
zsh-e8eb43fc308acb3f1a8ebada7633c097e5050e46.zip
Initial revision
Diffstat (limited to 'Functions/Zftp/zfget')
-rw-r--r--Functions/Zftp/zfget64
1 files changed, 64 insertions, 0 deletions
diff --git a/Functions/Zftp/zfget b/Functions/Zftp/zfget
new file mode 100644
index 000000000..878a36346
--- /dev/null
+++ b/Functions/Zftp/zfget
@@ -0,0 +1,64 @@
+# function zfget {
+# Get files from remote server. Options:
+# -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.
+#
+# 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
+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
+ ;;
+ *) 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
+ loc=${rem:t}
+ if zftp get $rem >$loc; then
+ [[ $time = 1 ]] && zfrtime $rem $loc
+ else
+ stat=1
+ fi
+ done
+ fi
+done
+
+(( $do_close )) && zfclose
+
+return $stat
+# }