about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-11 19:46:32 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-11 19:46:32 +0000
commit779b36d8442997a42de3fb5c032fbb984498182a (patch)
tree4bb72d633aaadd4028ed24502dd1724a4d3cedf6 /Functions
parenta008690d67199d689b54972fa27a3398c1c74a7e (diff)
downloadzsh-779b36d8442997a42de3fb5c032fbb984498182a.tar.gz
zsh-779b36d8442997a42de3fb5c032fbb984498182a.tar.xz
zsh-779b36d8442997a42de3fb5c032fbb984498182a.zip
zsh-3.1.6-dev-18 zsh-3.1.6-dev-18
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/.distfiles5
-rw-r--r--Functions/Misc/is-at-least33
-rw-r--r--Functions/Misc/nslookup49
3 files changed, 60 insertions, 27 deletions
diff --git a/Functions/Misc/.distfiles b/Functions/Misc/.distfiles
index 474c9cf74..e57056c03 100644
--- a/Functions/Misc/.distfiles
+++ b/Functions/Misc/.distfiles
@@ -1,5 +1,6 @@
 DISTFILES_SRC='
     .distfiles
-    acx allopt cat cdmatch cdmatch2 checkmail colors cx harden mere multicomp
-    nslookup proto pushd randline run-help yp yu zed zless zls zmv
+    acx allopt cat cdmatch cdmatch2 checkmail colors cx harden 
+    is-at-least mere multicomp nslookup proto pushd randline
+    run-help yp yu zed zless zls zmv
 '
diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least
new file mode 100644
index 000000000..b85e9b1a3
--- /dev/null
+++ b/Functions/Misc/is-at-least
@@ -0,0 +1,33 @@
+# $Id: is-at-least,v 1.1.1.1 2000/02/11 19:46:46 akr Exp $ -*- shell-script -*-
+#
+# Test whether $ZSH_VERSION (or some value of your choice, if a second argument
+# is provided) is greater than or equal to x.y.z-r (in argument one). In fact,
+# it'll accept any dot/dash-separated string of numbers as its second argument
+# and compare it to the dot/dash-separated first argument. Leading non-number
+# parts of a segment (such as the "zefram" in 3.1.2-zefram4) are not considered
+# when the comparison is done; only the numbers matter. Any left-out segments
+# in the first argument that are present in the version string compared are
+# considered as zeroes, eg 3 == 3.0 == 3.0.0 == 3.0.0.0 and so on.
+#
+# Usage examples:
+# is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
+# is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
+# is-at-least 586 $MACHTYPE && echo 'You could be running Mandrake!'
+
+function is-at-least()
+{
+    emulate zsh ; setopt LOCAL_OPTIONS
+    local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version
+    min_ver=(${=1})
+    version=(${=2:-$ZSH_VERSION} 0)
+    while (( $min_cnt <= ${#min_ver} )) {
+	while [[ "$part" != <-> ]] {
+	    [[ $[++ver_cnt] > ${#version} ]] && return 0
+	    part=${version[ver_cnt]##*[^0-9]}
+	}
+	[[ $[++min_cnt] > ${#min_ver} ]] && return 0
+	(( part > min_ver[min_cnt] )) && return 0
+	(( part < min_ver[min_cnt] )) && return 1
+	part=''
+    }
+}
diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup
index d59a5e66c..2103a839b 100644
--- a/Functions/Misc/nslookup
+++ b/Functions/Misc/nslookup
@@ -1,34 +1,33 @@
 # Simple wrapper function for `nslookup'. With completion if you are using
 # the function based completion system.
 
-setopt localoptions completealiases
+setopt localoptions localtraps completealiases
 
-local char line compcontext=nslookup pid
+local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
 
-trap 'print -p exit;return' INT
+zmodload -e zsh/zpty || zmodload -i zsh/zpty
 
-coproc command nslookup
-pid=$!
+trap 'return 130' INT
+trap 'zpty -d nslookup' EXIT
 
-while read -pk 1 char; do
-  line="$line$char"
-  [[ "$line" = *'
-> ' ]] && break
-done
-print -nr - "$line"
-
-line=''
-while vared -p '> ' line; do
-  print -p "$line"
-  line=''
-  while read -pk 1 char; do
-    line="$line$char"
-    [[ "$line" = *'
-> ' ]] && break
-  done
-  print -nr - "$line"
-  line=''
+pmpt=()
+zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
+zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
+(( $#pmpt )) || pmpt=(-p '> ')
+
+zpty nslookup nslookup
+
+zpty -r nslookup line '*> '
+print -nr "$line"
+
+while line=''; vared -he "$pmpt[@]" line; do
+  print -s "$line"
+  [[ "$line" = exit ]] && break
+
+  zpty -w nslookup "$line"
+
+  zpty -r nslookup line '*> ' || break
+  print -nr "$line"
 done
 
-print -p exit
-wait $pid
+zpty -w nslookup 'exit'