about summary refs log tree commit diff
path: root/Functions/Misc/nslookup
blob: d59a5e66ccb51a8f406ce72ff33e662a87c87399 (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 -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=''
done

print -p exit
wait $pid