Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/include

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


#!/bin/rc
# include [file...] - general include processor.
# replace lines starting "include file" with contents of "file".
# the $0 recursion is a bit subtle.
# requires an awk that invokes rc for system().
exec awk 'BEGIN { me = "'$0'" }
$1 == "include" && NF == 2 {
	if ($2 == FILENAME) {
		print me ": " $2 " infinite recursion" >"/dev/stderr"
		exit 1
	}
	r = system("if (! test -e " $2 ") exit missing; " me " " $2)
	if (r) {
		print me ": " $2 " missing" >"/dev/stderr"
		exit 1
	}
	next
}
	{ print }' $*

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.