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

Re: EOF in read-from-minibuffer causes delayed exit



Bart Schaefer wrote:
> Start a shell you don't mind exiting from.  Cut'n'paste the following:
> 
> autoload -U read-from-minibuffer
> insert-file() {
>     local REPLY
>     while [[ ! -r $REPLY ]]
>     do
> 	read-from-minibuffer 'Insert file: ' $REPLY || return 1
> 	[[ -r $REPLY ]] || zle beep
>     done
>     if zmodload -i zsh/mapfile
>     then RBUFFER="$mapfile[$REPLY]$RBUFFER"
>     else RBUFFER="$(<$REPLY)$RBUFFER"
>     fi
> }
> zle -N insert-file
> 
> Invoke this with ESC-x insert-file RET.
> 
> Now type ctrl-D.  Note feep.  Type ctrl-G.  Shell exits.

I think the answer is probably the following.  Certainly propagating
eofsent in quite the way it currently is is wrong, and it doesn't seem
right to have an EOF handled by zle in a recursive edit to mean exit the
main shell.  It *could* mean that, I suppose, and then the fix would be
to propagate the EOF properly, which is quite tricky when nested deep
inside user-defined widgets.  But I think I prefer this.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.64
diff -u -r1.64 zle_main.c
--- Src/Zle/zle_main.c	25 Feb 2005 15:10:01 -0000	1.64
+++ Src/Zle/zle_main.c	15 Mar 2005 10:42:39 -0000
@@ -1451,7 +1451,7 @@
     zlecore();
 
     locerror = errflag;
-    errflag = done = 0;
+    errflag = done = eofsent = 0;
 
     return locerror;
 }

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



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