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

PATCH: select behaving strange in 3.1.4 (2)



Goran Larsson wrote:
> $ cat select_weirdness
> #!/usr/local/bin/zsh
> 
> PROMPT3="What now?"
> select junk in A B C; do
>         echo $junk
> done
> $ 
...
(for ^D problem, see my previous patch)
...
> Even more weird is that by entering this another anomaly shows up:
> 
> $ . ./select_weirdness
> 1) A  2) B  3) C
> What now?^C                                        <-- enter control-C
> $ 
> $ . ./select_weirdness
> 1) A  2) B  3) C
> What now?2                                         <-- enter 2
> B
> What now?^D                                        <-- enter control-D
> zsh: do you wish to see all 1120 possibilities? n  <-- enter n
> What now?^C                                        <-- enter control-C
> 
> At this point control-C has stopped working.

The cause, you'll be interested to hear, is that at this point
the variable simple_pline is now zero so that the signal handler won't
set errflag.

simple_pline is supposed to test whether the shell is running with a
series of pipelines in front (i.e. as `cmd | builtin_commands'), in
which case the interrupt behaviour changes.  Unfortunately, I think
only Sven ever understood this stuff.  The best I can think of doing
is restoring simple_pline to its original value instead of
automatically zeroing it when the pipeline in question finishes, and
that's what this patch does.  It seems to work, but I wouldn't be too
surprised if there were side effects.

*** Src/exec.c.ctrlc	Sun May 31 12:28:46 1998
--- Src/exec.c	Fri Sep 18 17:02:09 1998
***************
*** 710,715 ****
--- 710,716 ----
  {
      int ipipe[2], opipe[2];
      int pj, newjob;
+     int old_simple_pline = simple_pline;
      static int lastwj;
  
      if (!l->left)
***************
*** 874,880 ****
  	    lastval = !lastval;
      }
      if (!pline_level)
! 	simple_pline = 0;
      return lastval;
  }
  
--- 875,881 ----
  	    lastval = !lastval;
      }
      if (!pline_level)
! 	simple_pline = old_simple_pline;
      return lastval;
  }
  
-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



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