da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1982-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* for the benefit of the dictionary generator */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin register Shell_t *shp = ((Shbltin_t*)extra)->shp;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* look for old=new argument */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* see if completely numeric */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* search for last line starting with string */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* set default starting range */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* set default termination range */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin range[1] = ((lflag && !edit)?hist_max(hp)-1:range[0]);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* check for valid ranges */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin errormsg(SH_DICT,ERROR_exit(1),e_badrange,range[0],range[1]);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* now list commands from range[rflag] to range[1-rflag] */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if((fdo=open(fname,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR)) < 0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin outfile= sfnew(NIL(Sfio_t*),shp->outbuff,IOBSIZE,fdo,SF_WRITE);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin hist_list(shp->hist_ptr,outfile,hist_tell(shp->hist_ptr,range[flag]),0,arg);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(!arg && !(arg=nv_getval(sh_scoped(shp,HISTEDIT))) && !(arg=nv_getval(sh_scoped(shp,FCEDNOD))))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Code to support the FC using the pad editor.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Exampled of how to use: HISTEDIT=pad
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin extern int pad_create(char*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* apollo */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* apollo */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* don't history fc itself unless forked */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Sfio_t *iop = sfnew(NIL(Sfio_t*),buff,IOBSIZE,fdo,SF_READ);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* read in and run the command */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * given a file containing a command and a string of the form old=new,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * execute the command with the string old replaced by new
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void hist_subst(const char *command,int fd,char *replace)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int c;