From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32044 invoked from network); 22 Aug 2023 19:08:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Aug 2023 19:08:03 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692731283; b=FsDHy9RALwUn23QEhhBTqV4AT0c1l4x2a6U+xg0LZCIvrwluWCDxDDS8gHIp4QwMX6O5Y525k9 vm7rHcZ2RTumilPjeSLqsmqMFWkYLTzd8DKnkwwkcg9prEu9uXZBk3zlW1Ba033qqVdB47O66t Ka+fLKy4xW+hC8g6ACjMOYmSK7Y8wOSfmBSBjfOyuMqkQZ4s/mO6zjs633IWKot83FexLVuPm5 PnKaOf3exUoWJwVsLpIToOvEOmy0L2GU+RyskWmu4suzrKOQ3yQNcdcIbkRZAjeX2/06Mkas06 1Hi3yWiCFNa8n4XRIsvs8tRKNc/wxuZli0nw325BYuV1lQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay7-d.mail.gandi.net) smtp.remote-ip=217.70.183.200; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692731283; bh=ppDJWgZ6+TGvWfVsTYTn6ax2bw1tTlI0Pn/noi8m6AI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:DKIM-Signature; b=q7EssBR9x0q2v//5otICuEKiSQ/u7alKueMR0GDEKfsafR2SZpBp8U0VFgeWPnOZKg6lAJV+ox +VavA/dXX4aJdM8SG/fKdQQv4gnbx0cvb/oCqaP5MNNElKDbQL39OxPM3c5NP8Qe/sc6YuKjj6 ePNbwhXsWhiYUnX8iUMbQAZ9FnBwGdI0vt8ejTIHl+UdHTG5kcN8RV75FY7M/NJpjAF3FrQ3R6 zBe1YygqGp7q3h3aAE1IeotuthVZk8fe5D76Y5KQYcO07l++6yO8rGvHNSW4n2IzMUSpGGXRDn ktqU8p7mWjr+w3oYCLJQTuPQ5Yw1K1GwenF3LozuGDvF3g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=V9/U2hdw+JYUKnuaJSEynOvraHLL/5ZCaLfnm+LAfAc=; b=CKgutPCFQdBG01XfkC6zU19TZf dXgYCukNE2bueSguaeNPK/+iVbe/miVoW+rnyZHMdHLLgqNfL3YOpNldCLQmeigi8BffHf38h0d1f IXWc1BHjQ0QNajVQ6jlSoNLbIxRi0VExc1RsYoNYAaSuN9Esy/p6ryQJAjCPbijPFA5YJ7gmVXjrV lZcQ2Ute/XKikZKKAHHP2giywyV8LL6FOgX+RffETk+OVJHKedBa2HhWurYtgD9LZS8cfEPYXb6jh SvVeQGEyjDHCY7ylJh3hUNjgTSwsCWM9vp/X3nmohIEktrl1PTo3bNsiN3Ytvo8eKLUHnLuaNBGyB gxnIbkng==; Received: by zero.zsh.org with local id 1qYWjT-000ME2-FR; Tue, 22 Aug 2023 19:08:03 +0000 Authentication-Results: zsh.org; iprev=pass (relay7-d.mail.gandi.net) smtp.remote-ip=217.70.183.200; dmarc=none header.from=chazelas.org; arc=none Received: from relay7-d.mail.gandi.net ([217.70.183.200]:37725) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1qYWf6-000LAy-55; Tue, 22 Aug 2023 19:03:32 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 69BC120005; Tue, 22 Aug 2023 19:03:31 +0000 (UTC) Date: Tue, 22 Aug 2023 20:03:30 +0100 From: Stephane Chazelas To: Budi , Zsh Users Subject: Re: Help find Zsh' Bash `read -N1 -p "Put here " var Message-ID: <20230822190330.qytgyr3oadewezvp@chazelas.org> Mail-Followup-To: Budi , Zsh Users References: <20230822174202.adcxbpipov7vsmc2@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230822174202.adcxbpipov7vsmc2@chazelas.org> X-GND-Sasl: stephane@chazelas.org X-Seq: 29189 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: 2023-08-22 18:42:02 +0100, Stephane Chazelas: [...] > with the caveat about NUL above. Actually, in bash, you'd > probably be better of using: > > LC_ALL=C read -rd '' -n1 var > > That is read up to one byte from a NUL-delimited record. So read > would return immediately upon the first byte received even if > it's 0. Beware of the effect on the exit status though. [...] Sorry, should have been: LC_ALL=C IFS= read -rd '' -n1 var While bash's read doesn't do IFS processing with -N, it does with -n, so you need to set IFS to the empty string for read as otherwise it would strip any character in $IFS if input before storing into $var. May be worth mentioning the sysread builtin from the zsh/system module which gives you more control when reading a fixed number of bytes (see info zsh sysread). -- Stephane