File: nslookup

package info (click to toggle)
zsh-beta 4.3.17-dev-0%2B20120621-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 19,804 kB
  • sloc: ansic: 95,966; sh: 5,899; makefile: 845; perl: 745; awk: 383; sed: 16
file content (48 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download | duplicates (13)
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
# Simple wrapper function for `nslookup'. With completion if you are using
# the function based completion system.

if [[ $argv[(I)-] -eq 0 && $argv[(I)[^-]*] -ne 0 ]]; then
  command nslookup "$@"
  return
fi

setopt localoptions localtraps completealiases

local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
local pager opager="$PAGER"
typeset +g -x PAGER=cat

zmodload -e zsh/zpty || zmodload -i zsh/zpty

trap 'return 130' INT
trap 'zpty -d nslookup' EXIT

pmpt=()
zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
zstyle -s ':nslookup' pager tmp &&
    [[ -z "$pager" ]] && pager="${opager:-more}"
(( $#pmpt )) || pmpt=(-p '> ')

zpty nslookup command nslookup "${(q)@}"

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 '(|*
)> '
  if [[ -n "$pager" && ${#${(f)line}} -gt LINES ]]; then
    print -nr "$line" | eval "$pager"
  else
    print -nr "$line"
  fi
done

zpty -w nslookup 'exit'