Zsh Mailing List Archive
Messages sorted by:
Re: unget a character
- X-seq: zsh-users 17632
- From: rahul <rahul2012@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: unget a character
- Date: Wed, 6 Feb 2013 10:33:09 +0530
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=A93g8KwcrFz8ZfGa4Ifjd+VZb+wgC2CUMWgakNG1SXY=; b=TeSTMU4HRDHYwOIkP+nkno/mBeWi2OXboCsixT4OtsEApY1aUJ37Uc+G40878PxBDG oeRdr4n7IUrIYJCmTDZgovno572eFNFM1m0OeBXGRjOonqcCSeqlmwXDxaiyrV9oz7PF KZdwIsTW15Y2SeZzHw43pmhTXqJpzgRU4vG3Pb0soxe+wwC8cnELG0csqkSKjLuFTBpt lShIIhtnjmUOY0FUFleA6B9r6yLXuseY1I3xmFihA3s6d1B4JDVqv4w3Vc/hi1cX+DSP q+a1Y8Dt3HA1/jC21ZMcjOBuHFLIxRlsLn8nfRDdEXTDLNiM+g1rwh1X5DT37e6q9kYo cQcQ==
- In-reply-to: <130205183313.ZM28561@torch.brasslantern.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CACQNQ9O2AFj21Avf4tB3GCSv_9QV_WVOsVkk+VwDuZjvfUCjyQ@mail.gmail.com> <130205183313.ZM28561@torch.brasslantern.com>
On Wed, Feb 6, 2013 at 8:03 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>wrote:
> On Feb 5, 8:53pm, rahul wrote:
> } How can i unget a character (taken in by read -k).
> } It would help me if i could unget a char in one part of my app, so it
> } be available in the main loop.
> If you are talking about an interactive shell reading input with ZLE, you
> can do it with "zle -U".
> If you're in some other way reading from a stream such as standard input,
> unget is not possible. You need a lower-level programming language with
> more direct control over things like stdio buffers. (Unget is not an OS-
> level operation, it's implemented in stdio or the equivalent.)
I am writing a shell program that uses "read -k" to get keys in a loop (I
have not yet got into zle). It branches off into functions and I wanted to
get a char in one function, and then reject it if it was not correct, so
the main loop could use it.
After asking this question, I realized I could do this programmatically, by
setting the unwanted key to a variable. The main loop would first check the
variable and use that value , if blank it could do a "read".
Messages sorted by: