From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 82c08db0 for ; Thu, 20 Feb 2020 22:59:32 +0000 (UTC) Received: (qmail 23173 invoked by alias); 20 Feb 2020 22:59:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45483 Received: (qmail 378 invoked by uid 1010); 20 Feb 2020 22:59:23 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25725. spamassassin: 3.4.2. Clear:RC:0(209.85.166.65):SA:0(-2.0/5.0):. Processed in 1.560644 secs); 20 Feb 2020 22:59:23 -0000 X-Envelope-From: mikachu@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.65 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UwfGAOYfDclYD+kSDFtQI1dLXqeoCVEZkJfxplPZkDU=; b=HCCI37rgdLLnlIrD5xbGzBLRZNoR9zwHkjKDa2IzpTA624d9Xc+SLdlL7HX1ZEM0fB u8n3QaGuy/BapgNMglkRh23GC0acweCSVmIrMU8O1GG7fU0lhCfQUjQUkLKVozGQhr6Z IldhyYAaV0yyn1hBUgN7tGdstJDkYuFy1s7i7IkPrQgDX42Jj60SlQXnz+fEx2D+N73M hamXvE3FycfFo+8mzzEFMGJcuAsPUgyrEigQPtYc0GcnQP2njIodLpQAfxzZxUXQDPd3 JXgQqLnVHv7d7UjVSSd5kaL4BMN3pkpXO4tMWRlUZpEy0GZ6BYhZZ02gIdF2iUMFb82u ATbQ== X-Gm-Message-State: APjAAAVld3esMJh9I0lcsTpfy0AeR7n2iOH7q+4UwgTfRwnxP9wjEmmn HpSZzpSAQSD02MyF6gGWBAzFdTWbwAJorvyUBj+zDA== X-Google-Smtp-Source: APXvYqzqa3HVJUnOW/4rWSux+mRXs3uIcxGzcJTjUPObLKyx/sjb4lzvzoNoZ+4ictfDxP+LzZo0ZKj6dBAz0IXW058= X-Received: by 2002:a05:6638:147:: with SMTP id y7mr28405260jao.115.1582239528929; Thu, 20 Feb 2020 14:58:48 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20200220190310.tms2xcwk3sjmqb76@localhost> References: <20200220190310.tms2xcwk3sjmqb76@localhost> From: Mikael Magnusson Date: Thu, 20 Feb 2020 23:58:48 +0100 Message-ID: Subject: Re: print -v with multibyte characters To: zsugabubus Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 2/20/20, zsugabubus wrote: > Hi, > > $ echo $ZSH_VERSION > 5.7.1 > $ export {LC_ALL,LANG}=3Den_US.UTF-8 > $ set -o multibyte && echo ok > ok > > Good: > $ print =C3=96=C3=93=C5=90=C3=B6=C3=B3=C5=91 > =C3=96=C3=93=C5=90=C3=B6=C3=B3=C5=91 > $ printf -v var =C3=96=C3=93=C5=90=C3=B6=C3=B3=C5=91; echo $var > =C3=96=C3=93=C5=90=C3=B6=C3=B3=C5=91 > > Bad: > $ print -v var =C3=96=C3=93=C5=90; echo $var > =C3=83=C2=B6=C3=83=C2=B3 > $ print -v var =C3=B6=C3=B3=C5=91; echo $var > =C3=B6=C3=B3=C5=83 This gets closer to correct, but seems to leave out the final byte or two, or change it somehow, diff --git i/Src/builtin.c w/Src/builtin.c index 168bf8863b..ed26717b5b 100644 --- i/Src/builtin.c +++ w/Src/builtin.c @@ -4848,8 +4848,7 @@ bin_print(char *name, char **args, Options ops, int f= unc) if (ret) free(buf); else - setsparam(OPT_ARG(ops, 'v'), - metafy(buf, rcount, META_REALLOC)); + setsparam(OPT_ARG(ops, 'v'), buf); unqueue_signals(); } return ret; @@ -4972,8 +4971,7 @@ bin_print(char *name, char **args, Options ops, int f= unc) if (ret) free(buf); else - setsparam(OPT_ARG(ops, 'v'), - metafy(buf, rcount, META_REALLOC)); + setsparam(OPT_ARG(ops, 'v'), buf); unqueue_signals(); } return ret; Incidentally you can use print -v var -f %s =C3=96=C3=93=C5=90; echo $var t= o work around the problem (the handling for -f uses different code which doesn't have the bug). --=20 Mikael Magnusson