Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/src/futharc/history.c

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


#include "rc.h"
#include "exec.h"
#include "fns.h"
#include "io.h"

void
whistory(tree *t){
	char* s;
	int fd, flags;
	io* o;
	var* v;

	if(!runq->iflag || !t)
		return;
	v = vlook("history");
	if(!v->val || count(v->val) != 1)
		return;
	if(v->fn)
		return;	/* fn history {echo $*>>$history_file} ? */

	s = v->val->word;
	flags = OWRITE;
	if((fd=open(s, flags))<0 && (fd=create(s, flags, DMAPPEND|0666L))<0){
		/* setvar("history", 0); */
		return;
	}
	
	o = openfd(fd);
	seek(fd, 0, 2);
	pfmt(o, "%t\n", t);
	closeio(o);
}

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.