#! /bin/sh

# This code is in the public domain
# Written by Robbert Haarman

usage="USAGE: bluetooth-host <hostname>"

if [ $# -lt 1 ]
then
    echo "$usage" >&2
    exit 128
fi

name="$1"

while read line
  do
  address=''
  for x in $line
  do
    if [ -z "$address" ]
    then
	address="$x"
    else
	if [ "$x" = "$name" ]
	then
	    echo "$address"
	    exit
	fi
    fi
  done
done < /etc/bluetooth/hosts

echo "Unknown host: $name" >&2
