Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/rc/sdiff

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


#!/bin/rc
# sdiff - compare files against sources

rfork en

fn usage {
	echo >[1=2] usage: `{basename $0} [diff/idiff options] [-f file] [-i] [file ...]
	exit usage
}

opts=()
files=()
iflag=0
while(~ $1 -*){
	switch($1){
	case '-?'
		usage
	case -f
		if(~ $#* 1)
			usage
		files=`{read -m $2}
		shift
	case -i
		iflag=1
	case -*
		opts=($opts $1)
	}
	shift
}
if(~ $iflag 0)
if(~ $#opts 0)
	opts=-cmr
if(~ $#files 0)
	files=($files $*)
if(~ $#files 0)
	files=`{pwd}

9fs sources

for(f in $files){
	f=`{cleanname -d `{pwd} $f}
	if(~ $iflag 0)
		diff $opts /n/sources/plan9^$f $f
	if not{
		tmp=/tmp/`{basename $f}^.$pid
		idiff $opts /n/sources/plan9^$f $f >$tmp && mv $tmp $f
	}
}
exit ''

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.