about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-01 14:48:28 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-01 14:48:28 +0000
commit61e68d70da5af5afe943f92cd94a8c96e78348d9 (patch)
tree1e88adbfc21452caedcb57af2880097a349f44e6 /Functions
parent14810d6df13e0564a606b74e4c4e918e80862e25 (diff)
downloadzsh-61e68d70da5af5afe943f92cd94a8c96e78348d9.tar.gz
zsh-61e68d70da5af5afe943f92cd94a8c96e78348d9.tar.xz
zsh-61e68d70da5af5afe943f92cd94a8c96e78348d9.zip
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Zftp/zfanon16
-rw-r--r--Functions/Zftp/zfget25
-rw-r--r--Functions/Zftp/zfopen16
-rw-r--r--Functions/Zftp/zftp_chpwd17
4 files changed, 55 insertions, 19 deletions
diff --git a/Functions/Zftp/zfanon b/Functions/Zftp/zfanon
index d8a9d06a3..9624d48d9 100644
--- a/Functions/Zftp/zfanon
+++ b/Functions/Zftp/zfanon
@@ -2,7 +2,7 @@
 
 emulate -L zsh
 
-local opt optlist once
+local opt optlist once dir
 
 while [[ $1 = -* ]]; do
   if [[ $1 = - || $1 = -- ]]; then
@@ -61,10 +61,20 @@ if [[ -z $EMAIL_ADDR ]]; then
   print "Using $EMAIL_ADDR as anonymous FTP password."
 fi
 
+if [[ $1 = */* ]]; then
+  1=${1##ftp://}
+  dir=${1#*/}
+  1=${1%%/*}
+fi
+
 if [[ $once = 1 ]]; then
-  zftp open $1 anonymous $EMAIL_ADDR
+  zftp open $1 anonymous $EMAIL_ADDR || return 1
 else
   zftp params $1 anonymous $EMAIL_ADDR
-  zftp open
+  zftp open || return 1
+fi
+
+if [[ -n $dir ]]; then
+  zfcd $dir
 fi
 # }
diff --git a/Functions/Zftp/zfget b/Functions/Zftp/zfget
index 878a36346..cee0290b3 100644
--- a/Functions/Zftp/zfget
+++ b/Functions/Zftp/zfget
@@ -1,10 +1,16 @@
 # 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.
+#        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
@@ -13,7 +19,7 @@
 
 emulate -L zsh
 
-local loc rem optlist opt nglob remlist time
+local loc rem optlist opt nglob remlist time cat
 integer stat do_close
 
 while [[ $1 == -* ]]; do
@@ -29,6 +35,8 @@ while [[ $1 == -* ]]; do
 	 ;;
       t) time=1
 	 ;;
+      c) cat=1
+	 ;;
       *) print option $opt not recognised >&2
 	 ;;
     esac
@@ -48,11 +56,16 @@ for remlist in $*; do
   fi
   if (( $#remlist )); then
     for rem in $remlist; do
-      loc=${rem:t}
-      if zftp get $rem >$loc; then
-	[[ $time = 1 ]] && zfrtime $rem $loc
+      if [[ -n $cat ]]; then
+	zftp get $rem
+	stat=$?
       else
-	stat=1
+	loc=${rem:t}
+	if zftp get $rem >$loc; then
+	  [[ $time = 1 ]] && zfrtime $rem $loc
+	else
+	  stat=1
+	fi
       fi
     done
   fi
diff --git a/Functions/Zftp/zfopen b/Functions/Zftp/zfopen
index fa9b4f81d..b264aeaba 100644
--- a/Functions/Zftp/zfopen
+++ b/Functions/Zftp/zfopen
@@ -7,7 +7,7 @@
 
 emulate -L zsh
 
-local optlist opt once
+local optlist opt once dir
 
 while [[ $1 = -* ]]; do
   if [[ $1 = - || $1 = -- ]]; then
@@ -31,12 +31,22 @@ done
 # both .netrc and .ncftp/bookmarks .  We could even try saving
 # the info in their for new hosts, like ncftp does.
 
+if [[ $1 = */* ]]; then
+  1=${1##ftp://}
+  dir=${1#*/}
+  1=${1%%/*}
+fi
+
 if [[ $once = 1 ]]; then
-  zftp open $*
+  zftp open $* || return 1
 else
   # set parameters, but only if there was at least a host
   (( $# > 0 )) && zfparams $*
   # now call with no parameters
-  zftp open
+  zftp open || return 1
+fi
+
+if [[ -n $dir ]]; then
+  zfcd $dir
 fi
 # }
diff --git a/Functions/Zftp/zftp_chpwd b/Functions/Zftp/zftp_chpwd
index f1c2d5311..0b5bbd7d5 100644
--- a/Functions/Zftp/zftp_chpwd
+++ b/Functions/Zftp/zftp_chpwd
@@ -1,13 +1,16 @@
 # function zftp_chpwd {
 # You may want to alter chpwd to call this when $ZFTP_USER is set.
 
-# Cancel the filename cache for the current directory.
-zftp_fcache=()
-# ...and also empty the stored directory listing cache.
-# As this function is called when we close the connection, this
-# is the only place we need to do these two things.
-[[ -n $zfcurdir && -f $zfcurdir ]] && rm -f $zfcurdir
-zfotherargs=
+# If the directory really changed...
+if [[ $ZFTP_PWD != $zflastdir ]]; then
+  # Cancel the filename cache for the current directory.
+  zftp_fcache=()
+  # ...and also empty the stored directory listing cache.
+  # As this function is called when we close the connection, this
+  # is the only place we need to do these two things.
+  [[ -n $zfcurdir && -f $zfcurdir ]] && rm -f $zfcurdir
+  zfotherargs=
+fi
 
 if [[ -z $ZFTP_USER ]]; then
   # last call, after an FTP logout