# rcmain: Plan 9 on Unix version
if(~ $#home 0) home=$HOME
if(~ $#home 0) home=/
if(~ $#ifs 0) ifs=' 	
'
switch($#prompt){
case 0
	prompt=('% ' '	')
case 1
	prompt=($prompt '	')
}
if(~ $rcname ?.out ?.rc */?.rc */?.out) prompt=('broken! ' '	')
if(flag p) path=(/bin)
if not{
	finit
	if(~ $#path 0) {
		path=(/bin /usr/bin)
		. <{sh -c 'echo $PATH |
				sed "s/^/path=(''/; s/$/'')/; s/:/'' ''/g"'}
	}
}
fn sigexit
if(! ~ $#cflag 0){
	if(flag l && test -r $home/lib/profile) . $home/lib/profile
	status=''
	eval $cflag
}
if not if(flag i){
	if(~ $TERM 9term){
		if(~ $#'fn#cd' 0)
			fn cd { builtin cd $1 && label `{pwd} }
	}
	if(flag l && /bin/test -r $home/lib/profile) . $home/lib/profile
	status=''
	if(! ~ $#* 0) . $*
	. -i '/dev/stdin'
}
if not if(~ $#* 0) . '/dev/stdin'
if not{
	status=''
	. $*
}
exit $status
