#!/bin/bash # Copyright (C) 2007 Michael Homer <=mwh> # Distributed under the GNU GPLv3+ without warranty of any kind. # Resolves an iname/XRI to a URI using the xri.net resolver. Outputs the final # URI after all redirects. Assumes a personal i-name if no specifier given. iname=${1/#[^=@($]*/\=$1} redir="http://xri.net/${1/#[^=@]*/=$1}" while [ -n "$redir" ] do uri=$redir redir=$(curl -sI "$redir"|awk '/Location:/{sub("\r$","",$2);print $2;exit}') if [ "http" != "$(echo $redir|cut -b-4)" ] && [ -n "$redir" ] then uri=$redir break fi done echo $uri