Plan 9 from Bell Labs’s /usr/web/sources/nix/nix/rc/bin/patch/defs

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


P=patches.lsub.org
S=sources.lsub.org
M=nix@lsub.org
PD=/n/$P/patch
SD=/n/$S/nix

fn fail {
	echo $* >[1=2]
	exit $"*
}

fn mountfs {
	if(! test -d $PD || ! test -d $SD){
		rm -f /srv/^($P $S)
		test -d $PD || 9fs $P || fail no patch dir
		test -d $SD || 9fs $S || fail no nix dir
	}
	
}

fn mkuniq { 
	uniq=`{basename $2}
	u=$uniq
	n=1
	while(test -e $1/$uniq){
		uniq=$u.$n
		n=`{echo 1+$n | hoc}
	}
	echo $uniq
}

fn cpfile {
	if(! test -e $1){
		echo $1 does not exist >failed ; cat failed>[1=2]
	}
	if(test -f $1)
		cp -x $1 $2 || { echo cp $1 $2: $status> failed ; cat failed>[1=2]}
	if(test -d $1){
		mkdir -p $2 || { echo mkdir $2: $status> failed ; cat failed>[1=2]}
		rm -rf $2/*
		dircp $1 $2  || { echo dircp $1 $2: $status> failed ; cat failed>[1=2]}
	}
	status=''
}

fn must {
	$* || fail $*
}

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.