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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25336 invoked from network); 22 Oct 2021 09:06:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Oct 2021 09:06:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634893566; b=IbLCKUq3UtIrPTBuYmv5C7mVyLnSMcO8UuzNqvYR/752tJPFzhzYY/RmkJUIQd7k4Ob9vIWiAF B80I27Ou6h2PAn49F6muqKxTgsQpV17bOApv/JRsCOYK3eafzozyn4jBOgN47yxoAFOLzxpIc3 ++VLI+sWeMB4jOzpn9UhWPlfe149ESgzle410jZjMLMKE6E0fqPj9rSpD2jLyT3L9oz5jjXO7A fNpezYUyJIAuBh4s3ShorrYnAZByNLaFCtwVl0SwykYx7p3LU3C6+3gYaiRIAkhVJmN2W63fl8 a+0HkwAKr02NELNbFfEyYNSF5vS1RPqbSCZNDrKW3wnFHg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay4-d.mail.gandi.net) smtp.remote-ip=217.70.183.196; 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=1634893566; bh=EL4yCdsuY/LdMWMdcSkRFpCYCAivAB9tQRFM/PN+P5c=; 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:Cc:To:From:Date:DKIM-Signature; b=nh2M1nvBpwFDl9i+4K26CK/TzAcheJhwc19YCVNy2lmBr1PF1ftbnRqDxeLxnWJqt3ctrctlTH ruvAMZV6CT4NplM5n/bW+5DJOeR7UO17sV1oGikukbC1fSO5DuuaTc9qKYXk2tqDIzjluhvkSk U/t0gPtTO93D+zRKTmApK7lRhYhDo56qJ5X51VANc8dBECKXgYmOqyiUaCRUybUGmGT6Z6lqFO t5TCo214WdF/gK6kGqFB6i/r9h+0sQY/hiiSaQG0TQYDYttHAFYw1DfOJ7l2Q4KgjOn511f3lr okiDsRe7r1+RUgpNaVJsHXKAvHBF6bj0DlK7mL82RIgAdQ==; 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:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=t2SYgZieGw106B0Um+dSrt41VVGfAyDqd8KIY2qcUhs=; b=rkvidKgkIn4Zh0b8PropSk+ShV zY2YXYo0dkSkI4GvCm7hC27kHggm/v3pOiisQv1F/F9sSQzcZXVEEwzaLb0IXGGjxFXAh9+344gaL QEjo/A5pWPgnxI+1FSHdC8FADkmPIA+IkKWq36GHUUVr2OHNNwA2JHMFfc8rL66GVUoRj8r05Az4b 5BZdArBBXh/4ZWM+oW9B0aYnNC7vlQBs5aCkaD9eEtPWzQlMrk9y+D4SZBqgTlvQpE0xxh6eJib3O 0XlEy3ibjtWNtK6DqdoMV7YVCfI5XoHYCpg3ZuftYmacxd5N6Xx+FNZhxOEX5jZirzCskO3wVK9w6 KK9fZ8NQ==; Received: from authenticated user by zero.zsh.org with local id 1mdqV3-000Fya-Es; Fri, 22 Oct 2021 09:06:05 +0000 Authentication-Results: zsh.org; iprev=pass (relay4-d.mail.gandi.net) smtp.remote-ip=217.70.183.196; dmarc=none header.from=chazelas.org; arc=none Received: from relay4-d.mail.gandi.net ([217.70.183.196]:44543) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1mdqUJ-000FFe-Sd; Fri, 22 Oct 2021 09:05:20 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id E71EEE0011; Fri, 22 Oct 2021 09:05:18 +0000 (UTC) Date: Fri, 22 Oct 2021 10:05:18 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: Pier Paolo Grassi , Zsh-Users List Subject: Re: read string containing null Message-ID: <20211022090518.ubd6ifyiyn65ap4z@chazelas.org> Mail-Followup-To: Peter Stephenson , Pier Paolo Grassi , Zsh-Users List References: <899710302.733700.1634821721465@mail2.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <899710302.733700.1634821721465@mail2.virginmedia.com> X-Seq: 27261 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: 2021-10-21 14:08:41 +0100, Peter Stephenson: [...] > If you're not trying to read a line, don't use read. If you "zmodload zsh/system" > there's a sysread command which is more useful for lower level operations. [...] Yes, though sysread does only one read() of a fixed size (8KiB be default), so you'd need to call it in a loop. Other options are: cmd | LC_ALL=C read -u0 -k999999999 var Though it allocates as much memory. And there's: var=$(cmd; print .); var=${var%.} To get the contents of a regular file into a variable, there's also zmodload zsh/mapfile var=$mapfile[path/to/file] -- Stephane