summary refs log tree commit diff
path: root/Functions/Misc/nslookup
blob: 15afb2ff19111bc717138397107056c6d9f9db44 (plain) (blame)
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
# Simple wrapper function for `nslookup'. With completion if you are using
# the function based completion system.

setopt localoptions completealiases

local char line compcontext=nslookup pid

trap 'print -p exit;return' INT

coproc command nslookup
pid=$!

while read -pk1 char; do
  line="$line$char"
  [[ "$line" = *'
> ' ]] && break
done
print -nr - "$line"

line=''
while vared -p '> ' line; do
  print -p "$line"
  line=''
  while read -pk1 char; do
    line="$line$char"
    [[ "$line" = *'
> ' ]] && break
  done
  print -nr - "$line"
  line=''
done

print -p exit
wait $pid