Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/lib/rcmain

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


# rcmain
if(~ $#home 0) home=/
if(~ $#ifs 0) ifs=' 	
'

if(~ $rcname ?.out) {
	oldprompt=$prompt
	prompt=('broken! ' '	')
}
if not {
	if (~ $#oldprompt 1 2)
		prompt=$oldprompt
	switch($#prompt){
	case 0
		prompt=('% ' '	')
	case 1
		prompt=($prompt '	')
	}
}

if(flag p) path=/bin
if not{
	finit				#  import functions from env
	if(~ $#path 0) path=(/bin .)
}
fn sigexit

fn rclogin {
	if(flag l) {
		# print warning only if not a remote command
		if({~ $#cflag 0 && ! ~ $service rx} && test ! -f /_fs_main)
			cat /cfg/$sysname/warning >[2]/dev/null
		if(/bin/test -r $home/lib/profile)
			. $home/lib/profile
	}
	status=''
}

if(! ~ $#cflag 0){			# rc -c cmd: remote command
	rclogin
	fn rclogin
	eval $cflag
}
if not if(flag i){			# interactive shell
	rclogin
	fn rclogin
	if(! ~ $#* 0)
		. $*			# source any arguments
	. -i '#d/0'			# read stdin interactively
}
# else non-interactive use
if not if(~ $#* 0) {
	fn rclogin
	. '#d/0'			# read stdin non-interactively
}
if not{
	status=''
	fn rclogin
	. $*				# source any arguments
}
exit $status

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.