Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

"breaks" variable incorrectly reset in "doshfunc()"



Hello,
	here is a bug report and a patch for zsh-3.0.2. First the description
of the bug:

	- run "zsh" (the bug happens even with with the "-f" flag and no
          /etc/zshenv)

	- define the "TRAPDEBUG()" function to be anything, eg:

		TRAPDEBUG()
		{
		  return 0
		}

	- enter (for this to be really useful, you would put
	  "set -o AUTO_PUSHD" and "export DIRSTACKSIZE=10" in eg ".zshrc")

			select dir in `dirs`
			do
			  eval cd $dir
			  break
			done

	- the bug is that the "break" in the above loop is not executed, so
	  that you have to exit the loop with a "^D", otherwise you remain
	  in the loop forever.

My analysis is that "doshfunc()" is called because TRAPDEBUG is set and
this function resets the "breaks" variable to 0 a bit too early. See below
for the patch I propose (I don't know if it will break something else.)


						Martin

--
Martin Ouwehand               Tél +41 21 693 22 29         ouwehand@xxxxxxxxxxx
Service Informatique Central                          Central Computing Service
Ecole Polytechnique Fédérale - Lausanne - Swiss Federal Institute of Technology
================== PGP public key: http://sehp1.epfl.ch:8001 ==================



*** zsh-3.0.2.orig/Src/exec.c	Tue Dec 17 21:14:11 1996
--- zsh-3.0.2/Src/exec.c	Mon Jan 27 17:14:16 1997
***************
*** 2484,2489 ****
--- 2484,2490 ----
      char **tab, **x, *oargv0 = NULL;
      int xexittr, oldzoptind, oldlastval;
      LinkList olist;
+     int obreaks;
      char *s, *ou;
      void *xexitfn;
      char saveopts[OPT_SIZE];
***************
*** 2533,2538 ****
--- 2534,2540 ----
  	}
  	PERMALLOC {
  	    olist = locallist;		/* save the old locallist since shell functions may be nested */
+ 	    obreaks = breaks;
  	    locallist = newlinklist();	/* make a new list of local variables that we have to destroy */
  	} LASTALLOC;
  	locallevel++;
***************
*** 2552,2558 ****
  	zfree(locallist, sizeof(struct linklist));
  
  	locallist = olist;	/* restore the old list of local variables */
! 	breaks = retflag = 0;
  	freearray(pparams);
  	if (oargv0) {
  	    zsfree(argzero);
--- 2554,2561 ----
  	zfree(locallist, sizeof(struct linklist));
  
  	locallist = olist;	/* restore the old list of local variables */
! 	breaks = obreaks;
! 	retflag = 0;
  	freearray(pparams);
  	if (oargv0) {
  	    zsfree(argzero);



Messages sorted by: Reverse Date, Date, Thread, Author