#!/Users/yarek/plan9/bin/rc
# Tells the best cpu to run commands based on context.
#
# To publish: cp $% /n/sources/contrib/yk/lab/unix/
. /Users/yarek/plan9/bin/9.rc
if(~ $#* 1)
dir = $1
if not {
if(~ $#dir 0 && ! ~ $#% 0){ # sam, acme
if(~ $"% */) # acme
dir = $"%
if not
dir = `{dirname $"%}
}
if(~ $#dir 0 || ~ $dir '')
dir = `{pwd}
}
if(! ~ $dir /n/* $HOME/n/*)
exit 'not remote'
r = `{echo $dir | sed 's!^(' ^ $HOME ^ ')?(/n/[^/]*).*!\2!'}
if(remote = `{cat $r/etc/hostname >[2]/dev/null}) {
echo $remote
exit
}
# allow unmounted remotes
remote = `{basename $r}
if(! ~ $remote local remote other sources) {
echo $remote
exit
}
exit 'unknown'
|