aboutsummaryrefslogtreecommitdiff
path: root/Functions/Zftp/zfautocheck
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:41 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:41 +0000
commit206237c8ec4b7619d9e70a75004cd1ae1066b0a0 (patch)
treeff703cbc295605f90755edb68672ed2de11f4a81 /Functions/Zftp/zfautocheck
parent8ceb54fbc2f879e0e80f58c18761bd54db07e5f7 (diff)
downloadzsh-dot-zsh-199904280524.tar.gz
zsh-dot-zsh-199904280524.tar.xz
zsh-dot-zsh-199904280524.zip
Diffstat (limited to 'Functions/Zftp/zfautocheck')
-rw-r--r--Functions/Zftp/zfautocheck33
1 files changed, 33 insertions, 0 deletions
diff --git a/Functions/Zftp/zfautocheck b/Functions/Zftp/zfautocheck
new file mode 100644
index 000000000..abb994061
--- /dev/null
+++ b/Functions/Zftp/zfautocheck
@@ -0,0 +1,33 @@
+# function zfautocheck {
+# This function is used to implement auto-open behaviour.
+#
+# With first argument including n, don't change to the old directory; else do.
+#
+# Set do_close to 1 if the connection was not previously open, 0 otherwise
+# With first arguemnt including d, don't set do_close to 1. Broadly
+# speaking, we use this mechanism to shut the connection after use
+# if the connection had been explicitly closed (i.e. didn't time out,
+# which zftp test investigates) and we are not using a directory
+# command, which implies we are looking for something so should stay open
+# for it.
+
+# Remember the old session: zflastsession will be overwritten by
+# a successful open.
+local lastsession=$zflastsession
+
+if [[ -z $ZFTP_HOST ]]; then
+ zfopen || return 1
+ [[ $1 = *d* ]] || do_close=1
+elif zftp test 2>/dev/null; then
+ return 0
+else
+ zfopen || return 1
+fi
+
+if [[ $1 = *n* ]]; then
+ return 0
+elif [[ -n $lastsession && $ZFTP_HOST = ${lastsession%%:*} ]]; then
+ zfcd ${lastsession#*:}
+fi
+
+# }