[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exec >[2] err.out



> Non-command specific redirection, as in
> 	exec >[2] err.out
> doesn't seem to have any effect in es.

ah, we were wondering when someone would find that.  that's not a  
bug, that's a feature.  looking at it under a microscope: (es -nx)

	;; exec >[2] err.out
	%create 2 <>{%one err.out} {exec }
	;; 


which does the create (causing a fork) and then the exec.  what you  
want is the opposite order of operations:

	;; cat t
	exec {>[2] err.out}
	ls foobar
	;; es t
	;; cat err.out
	foobar not found
	;; 


unfortunately, there's a bug in prim-io.c which prevents this from  
working.  here's a patch, which will also be included in 0.69:

*** prim-io.c.old	Fri Oct  9 09:47:58 1992
--- prim-io.c	Fri Oct  9 09:48:51 1992
***************
*** 57,65 ****
  		panic("redirection not handled");
  	}
  	lp = lp->next;
! 	exit(exitstatus(eval(lp, NULL, FALSE)));
! 	/* NOTREACHED */
! 	RefEnd2(str, lp);
  }
  

  PRIM(open) {
--- 57,67 ----
  		panic("redirection not handled");
  	}
  	lp = lp->next;
! 	lp = eval(lp, NULL, FALSE);
! 	if (parent)
! 		exit(exitstatus(lp));
! 	RefEnd(str);
! 	RefReturn(lp);
  }
  

  PRIM(open) {