Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/bin/rc/cadet

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


#!/bin/rc

rfork en

delim='⊢⊣'
file=''

fn printfile {
	shift
	if(! ~ $#* 0)
		file=$1

	if(~ $file '')
		echo 'No filename; specify one.'
	if not {
		cat $file
		echo $delim
	}
}

fn writefile {
	shift
	if(! ~ $#* 0)
		file=$1

	if(~ $file '')
		echo 'No filename; specify one.'
	if not {
		{
			# select entire file
			echo '?'$delim'?,$d'
			echo '0,$p'
			echo q
			echo q
		} | sam -d /dev/text > $file >[2]/dev/null
	}
}

if(! ~ $#* 0) {
	file=$1
	cat $1 >[2]/dev/null || echo 'New file.'
}

echo $delim

while () {
	c=`{read}
	switch($c) {
	case d
		echo $delim
	case p
		printfile $c
	case q
		exit
	case w
		writefile $c
	}
}

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.