Plan 9 from Bell Labs’s /usr/web/sources/contrib/rog/sh-examples/f2cenv.sh

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


# simple ``environment variable'' server
load file2chan std
(file2chan /chan/env
	{
		rescue 'bad $ arg' {} {
			fid := ${rget fid}
			v := rq^$fid
			(if {! ~ $#$v 0}
				{rread ${quote $$$v}}
				{rerror 'no variable name written'}
			)
		}
	}
	{rq^${rget fid} = ${rget data}}
	{rq^${rget fid} = ()}
)

fn getenv {
	var := $1
	{echo -n $var >[1=3]; /usr/rog/limbo/read 8192 0 <[0=3]} <>[3] /chan/env
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].