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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31553 invoked from network); 21 Oct 2021 13:32:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Oct 2021 13:32:03 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634823123; b=G1l6iBrF9EcQbYrWmiCFPOAOLC61SqQ7dZ5V4+hoPDsFhQTkqEVtIIL1XF6kFxqBjOnCZ3niwO 4CTTph0E8odm/2w/FiNER1LDP1NaN8RQZmlWJppw7CPhFOtyyPM+B9MLSmd1Qhbr11k/Hwfaic JvcBMQ9h/OuIVtC3O8UUqfrEQfE1mQvTWlYQ379gJdtbQPTykQEPNUXYn+gTse6yL8EiCqYfAk glxwGXW7IZ7W4NA57oywN6Q2cFVxZYoarUqzvGmlUek+ilbYT3eaL7Fe9NUI87aasnEY7hNKb+ dRpfIwz6gAIqoP/OXgSmoREdJLUxmRM5Q9pw5dIzR/a1dw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f48.google.com) smtp.remote-ip=209.85.166.48; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1634823123; bh=TGZJxXbRZ9FjscXCR+XUQtqmCBD0lp7av+MNuOZrqfs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=O8YnB7bTRXKnaktm5pxUFwn+JrtDOENoGE8RYLxo4yexTS6xujNX0nSF08VK2dwWYMk4DAKcTn lXRtTvo+k06hbtJ7Mphnl1AgE7dZhL5VhIYVi9dt0zaNqkbTMA00varRwcN7lwTglBR+XAoKNe xh360xWbGybkeUC4WZgTvrplFy+M/9phtgg3v27qpCdUnfNZIM/CC/BkFv+Z+0KxYxrzxk0w/u zEvemcsqJODHNotv/NGRYbxYszTO8jR18l8nb6c8OWA4/fKPoKGj9OY2FIDFGP1BNs7bkyXxRX HraH0CcngVZpTEaVaAKgAqdS3X2Aao7NvYvLG66p9S44bw==; 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:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=YgErN7RUUzXVqtzs9o9s0D82M2SJKPytwL8Tr1sNFCQ=; b=QsFxrEfyKBgZWoQmVgjGK3U0sX mIC+DJ+YCCKCd2i1mH0d7IEIv3IKEfRr3C4goIge1sB9Oiazz/MG4I2Rlb5DmJmZMbwtGItv/mluy eWxAPOvdIoiHPG1Tv55XfkLSCqESikerjr82E4eZkpixSKB8GOh6TcjVZfyMWtyTwE1hQK/GJt3av zMC2BZwyNTN4qyQ+jl1G5eo1ug0QAl1F2tcHrB/AcWhac+aYwJ6FJD1RjNyRPQpwq5dYWj0vHness AEJSbv86wWtkYbRdPgaP24Y7sQNkR3cXdBh70HVvaJ7esK/RUvOmynTCdb5Vysl9PtN3UxmOtberF AtFWBmGA==; Received: from authenticated user by zero.zsh.org with local id 1mdYAt-0006to-7p; Thu, 21 Oct 2021 13:32:03 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f48.google.com) smtp.remote-ip=209.85.166.48; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f48.google.com ([209.85.166.48]:40664) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mdYA2-0006Bp-Pq; Thu, 21 Oct 2021 13:31:11 +0000 Received: by mail-io1-f48.google.com with SMTP id x1so941965iof.7 for ; Thu, 21 Oct 2021 06:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YgErN7RUUzXVqtzs9o9s0D82M2SJKPytwL8Tr1sNFCQ=; b=FjTohLA66CXERtUUevEb1pi8JWfAWV3NyEVH5aZGUwtDFG9NNM8MKquwgEnMaRvEQ8 flTKuoMzVnS6EQCoBF1yhcZhRJzDZTa6FUhqAsNGNEmeKBnLUHZEcvDRKRD5XiNsJemi 16613o7FnPZKU1s36HZYuXJi3CdKmIoaNR6KQLEdcDvECWRbHi8DL/eoNTqAht/Qp/rx ZAlpGbC3xRYuFcR5JQYC4KIhQIIjwTYCv6MNcMuWF5WkoFzPH0inPfzTEO2SaBx5BRAx vWILiNOLMao7VcqHRBQ4x5DlkoiJmt/r7NchlhTO+02vr6sK0ZAlMMx3oXbSVVJI9b+h 4/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YgErN7RUUzXVqtzs9o9s0D82M2SJKPytwL8Tr1sNFCQ=; b=sb1pSlt59j6Zj76BaK+a2tkqHhbmvyzrXFvms6igltcr61/7W5fulBxOWo/R9KI7yI Hw48Nh2MrVJWWlE4nba2Dw6ccYp5pV4zODoXJkkf4fhwTTQIf6PyTg3rdjKLrPWEMC+t N59O809uSUvwmanMgLMaBWPIC2fCi87dk+5X3q67Vkp3c0GmWN6EzL+dHf4EuL1W+mgy rDBsxuwDynFd887drWuV3dP13Jl9YmgXo9EnG3PswkMuID6qXJswJ3mnmmoNCRLICp+h J6C41K6oZZK8Y/bqV4WqVig5BtL+Bg11rl5n2PRPVQqCEDoTB0meQQXxgGvFZjrllCtX QNqw== X-Gm-Message-State: AOAM530al+hTYgSnJ4otq3pzP02LGAu8VuGicABYUQAQE8+iCZsOxAEc h0Nka4j+p/QfhNuLpfVRkHKyb1ESR642Ol9iC0k= X-Google-Smtp-Source: ABdhPJzj26QdM8KGIqOQyaGg3XaQGd3ibGWzwaizGDE2mXOcPx1n/DCXxmFUSTwSMBjQg1Xx8oSaH9plP/pPn6xyVOI= X-Received: by 2002:a05:6602:199:: with SMTP id m25mr4044244ioo.173.1634823069444; Thu, 21 Oct 2021 06:31:09 -0700 (PDT) MIME-Version: 1.0 References: <899710302.733700.1634821721465@mail2.virginmedia.com> In-Reply-To: <899710302.733700.1634821721465@mail2.virginmedia.com> From: Pier Paolo Grassi Date: Thu, 21 Oct 2021 15:30:32 +0200 Message-ID: Subject: Re: read string containing null To: Peter Stephenson Cc: Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000532ecd05cedce865" X-Seq: 27256 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: --000000000000532ecd05cedce865 Content-Type: text/plain; charset="UTF-8" Yes, I want to read the whole stdin in a single operation, so the -d was there to disable stopping at newline It seem that instead made read stop at null bytes I worked around this limitation with: xx=$(echo -e - a$'\000'b; echo .); xx=${xx[1,-2]}; echo -n - $xx ab but I will try also your suggestion, thanks Pier Paolo Grassi Il giorno gio 21 ott 2021 alle ore 15:08 Peter Stephenson < p.w.stephenson@ntlworld.com> ha scritto: > > On 21 October 2021 at 13:35 Pier Paolo Grassi > wrote: > > Hello, I just found out: > > > > echo -e - a$'\000'b | IFS='' builtin read -r -d '' xx; echo -n - $xx > > result is "a" > > > > is it possible for builtin read not to stop an null bytes? I found > nothing > > in documentation. > > thanks > > I think -d '' is telling it to treat NULL bytes as a delimiter. Take that > out. > > 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. > > pws > --000000000000532ecd05cedce865 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes, I want to read the whole stdin in a single operation,= so the -d was there to disable stopping at newline
It seem that instea= d made read stop at null bytes
I worked around this limitation=C2= =A0with:

xx=3D$= (echo -e - a$'\000'b; echo .); xx=3D${xx[1,-2]}; echo -n - $xx
ab

but I will try also your suggestion, thanks

Pier Paolo Grassi


Il giorno gio 21 ott 2021 alle ore 15:08 Peter Stephenson &= lt;p.w.stephenson@ntlworld.c= om> ha scritto:
> On 21 October 2021 at 13:35 Pier Paolo Grassi <pierpaolog@gmail.com> w= rote:
> Hello, I just found out:
>
> echo -e - a$'\000'b | IFS=3D'' builtin read -r -d '= ;' xx; echo -n - $xx
> result is "a"
>
> is it possible for builtin read not to stop an null bytes? I found not= hing
> in documentation.
> thanks

I think -d '' is telling it to treat NULL bytes as a delimiter.=C2= =A0 Take that out.

If you're not trying to read a line, don't use read.=C2=A0 If you &= quot;zmodload zsh/system"
there's a sysread command which is more useful for lower level operatio= ns.

pws
--000000000000532ecd05cedce865--