From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4460 invoked by alias); 6 Feb 2013 07:56:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17632 Received: (qmail 16139 invoked from network); 6 Feb 2013 07:56:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.214.180 as permitted sender) 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== X-Received: by 10.182.123.49 with SMTP id lx17mr19989070obb.63.1360127009322; Tue, 05 Feb 2013 21:03:29 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <130205183313.ZM28561@torch.brasslantern.com> References: <130205183313.ZM28561@torch.brasslantern.com> From: rahul Date: Wed, 6 Feb 2013 10:33:09 +0530 Message-ID: Subject: Re: unget a character To: Bart Schaefer Cc: Zsh Users Content-Type: multipart/alternative; boundary=f46d0444eeff3d781f04d5073ffa --f46d0444eeff3d781f04d5073ffa Content-Type: text/plain; charset=UTF-8 On Wed, Feb 6, 2013 at 8:03 AM, Bart Schaefer 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 > will > } 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". -- rahul --f46d0444eeff3d781f04d5073ffa--