Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: use of "less" in function and interrupt
- X-seq: zsh-workers 38899
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: use of "less" in function and interrupt
- Date: Wed, 20 Jul 2016 20:40:47 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=AScyXhwQ+48s8ODbA9UFOD8mg7UpyE4AhqUQR0yRCsM=; b=wPWJDbUpM1xaizlFpPh85WDy8ux3dVJ14ycjSeBRcNgU1vUrf02rrI0ARjxD3RDweh xgFHdgjASmSnK8X1WVsnoi1tht/Nl7UDcc8O3txPUNASJPzlErlPnoly3uxM1xjbvlRM qt7Dmdb5WitfnqK/apVPiF7XxAo7sys95E39GJkuyauz0EdL6NAOEFBbCaJNgIePbfL2 And4Z31ZkyLWSVMgyYk6W4qTZ4a+ITKadEjHTaRjbgw2ifbhpkMYxifCn8BA/xXioZs7 QMxV5tJ3RPTGVYqVR9DkQ3Rx3gSezVMShXQJJ46JjEpIlVtt+N4rB4WqX89uxqNK/kac dzNQ==
- In-reply-to: <20160720132113.1d70a4c0@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160720113633.GA17431@zira.vinc17.org> <20160720132113.1d70a4c0@pwslap01u.europe.root.pri>
On Jul 20, 1:21pm, Peter Stephenson wrote:
} Subject: Re: use of "less" in function and interrupt
}
} On Wed, 20 Jul 2016 13:36:33 +0200
} Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
} > With zsh 5.2, if I type:
} >
} > zira% tless() { less "$@"; }
} > zira% sleep 5 | tless
} >
} > then "less" is left stopped in background after I type a key.
After you type ^C, you mean?
} Interestingly, I can get this to happen with
}
} sleep 5 | { less }
In both cases it works as expected provided that "sleep 5" has exited,
so you have to interrupt the sleep.
} but not
}
} sleep 5 | ( less )
}
} I'm not sure what that says about job control, which I've never really
} understood, but the two cases should be very close as in the second the
} shell knows it's about to exit and should exec less without an extra
} fork.
I believe the difference is that in both the functin case and the curly
brackets case you have a "current shell job" at the tail of the pipeline;
"less" is a subjob of that current shell job. In the other cases you
have a true external job at the end of the pipeline; you're correct that
the subshell exec's less, so it's equivalent to piping directly to less.
} I'm guessing that in the failing cases less is somehow being
} detached from the terminal while in the other cases it isn't and, when
} you quit less, normal service is resumed.
Pretty much, yes. I think what's happening is that the "current shell
job" is noticing that a ^C was delivered and therefore stops waiting
for its subjobs, not noticing that that "less" has ignored the signal
and continued on anyway.
Probably there's some point where the one last wait is needed, within
the cleanup of jobs in the current shell, to make sure that all the
subjobs really did go away. I suspect this to be related to the
breakup of errflag into ERRFLAG_ERROR and ERRFLAG_INT.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author