From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 9439C2480E for ; Thu, 22 Feb 2024 23:32:05 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708641125; b=T8YVhpeiLREmm1DVFa3HRgD5lTFHpeNJKzzjDy8NSJN2vR8NUYBccnuelwuW2o0cMdNDFzMrjT 7+LiC09oWcQXd4xPo+oSo9FoEimbqyGs6TPSvTu1D4scykbuVdQCtIgSwiCDbxJQFSh6ClcNGo /oQm9JK5lGMtaOwM0f6kQFxWnU1oFS4xA6wHyXAYzC9CWglo4jvDnGiCJLH4XOUF1+mdSh+TLY YC3J7SK2XZHDg5WT9CfmXuB/lq2MEdPd4Nrh9DYLLPxE7cDWDHROCgvV5TFMM7Qhfmbugpy0WP WMf7tE8K53Wyg+KjxrcqryJQLx02uoXSdkEy0FmYat6xRw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1708641125; bh=iZvcvMe937hQ0Im33xB3yRvR1p5gcLySlQXB+OooyW4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Qi+BxvqJbkR/qCnhrp2/p10peAn+4kg5IKskaQ/+xs0ngFsm8tZ5dgXpAoA8M8aCglDaRCpjoJ kYnlqs7zLQpg5GRPQfWI4i8LHhCGC060GRrIbHzA8GCya29ah3dBECl/LD56Q4+c8TnYZrP4c9 VUuclNmBkX4mkA60Szta+phydhxHs80mZnWI+iOLp3Ep1XPwciK7chAotEF3Dcuw9R7EztIlfs cDOzoWfqbRN0rII8t3L64zObj9KGKZMp5r8XNcnBEXJyHSbDjbhYjoeGwmEtyvlSuvAiygRtyO 5ZMshHRcW2SrXpWgODBw85VmMr9lfjGW9+LuMJ0p8TvgYA==; 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-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=57rF27NFL1t7of2pdTu1Nn4YSIelBluUYt7iEDwTW/s=; b=Ep1Ykcx4cEs73CO7wDCa/TWcNM mOdSTMcUsVTGPwhWXzKO+29/3vxVg74tB5WIybYosJ3Y49ZySZOhduWsRDMLhW/gKBMlVmBFg/D7+ wxsTEjBIOyNkP+Ft8ipUhzDriwFDNzmEZKjDhzzapvTrg7xHVHE2o974jHo4fUH4iq23Xp6QNcSAD B8KG/L216Cp86dS+hVazfzocO4i0sO1ysreS4gn+hvHsNMBerjuXRfrym/938v5HHpwN/wgNUzY7O KUgtGXlVUjdoCq67z/u9MxvSlMXE044UzhXgCQt2uNYRHpj0HO0aYXszQD4fZ9qlgo+o065Q9J+g4 Vp5mn0Aw==; Received: by zero.zsh.org with local id 1rdHbm-000Fke-Mt; Thu, 22 Feb 2024 22:32:02 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f44.google.com ([209.85.218.44]:44220) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rdHbA-000FRU-72; Thu, 22 Feb 2024 22:31:25 +0000 Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a26fa294e56so40905366b.0 for ; Thu, 22 Feb 2024 14:31:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1708641083; x=1709245883; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=57rF27NFL1t7of2pdTu1Nn4YSIelBluUYt7iEDwTW/s=; b=kgaImatgRlA34Cm9yOeGUgoPyNH6LfvBPEYNzIzbIw1uS6p1bQ9GTfs9ACOKAhqUN7 4B8MXLWHybWVfnrP1d1il7uzq8j40JmhLNx8qs3sT5T9uX4HhsuBdwCbOZ5BuDSLz0fA MmQzrB5oJ60InEdWq4L9K8hVjJNJZ+ZdAA+966XzM+tmeo+zDOIwOzEUsU4ueh0yvnsq dlBs53S2HNo/MypAnF6dVBjTi+ZS50a8jSfzQU9XhfRvq2mP2l9mqQPqCLTAYSC11cFC J/d8Nb6Y25Hj+gIhJtD/TeYjjqYHcy2N+I6w78PuDMpUQC8ZGZ9rN/Ii26NGuOMcnl2l ve3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708641083; x=1709245883; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=57rF27NFL1t7of2pdTu1Nn4YSIelBluUYt7iEDwTW/s=; b=tYzxd2MCmMZ162OhnXtleYWY09SU1/jHAlyKRShcHU7hVDK/bNewjQs48oMJNvfaNz dU4anTxTd+g5ntcwhoSxAzfpZ/0emqy/gyQ4jL2tMCs4IF0wsY7SF8oNS8JLqXYP5lC5 MH+ldZnT1YabEY/PgWJ3LembFAzu2c9kN5jdFvc55mDBgEVw+RswftbmXrElRNKJZ4A5 arrAMO7Lz35mpy2hmOEFIwuC/dAh+PnffPshJ/dgENE1BJuXNcYP9juYe0uPfpukIJgz AgXeSO/NDkZ7lhn9Teg0ADZ4WQ3/63WPYENO/GjtE5O1nhZHW0p1KX/y5Ci2nyozQWkW Lx6g== X-Gm-Message-State: AOJu0Yyr1zI+6Sp+bydCSLHrIZwoz9BfDRL5KWJMHxPGvQ01H1e5/ANr DghPnDxptlsiH/k5mmeDXgGtOUFdxZP2t9Qs49wg8MdHLQVuj7JHAqChc4Rg5GLUCZ5UUMQ12RN sBDmfux5pDKZld5nZsO+UZG1FyhFPzlgMaa51D4Irm5r77l4yig== X-Google-Smtp-Source: AGHT+IGe7vODb7T5FLoP/w9rsNt++aetzkGTT5ThLvS5W20/wSVdeSKlzTZ00vQnuAy5/s/PMYbHCb53WRF8ySnoLKk= X-Received: by 2002:a17:906:a948:b0:a3e:8300:7647 with SMTP id hh8-20020a170906a94800b00a3e83007647mr118488ejb.63.1708641083408; Thu, 22 Feb 2024 14:31:23 -0800 (PST) MIME-Version: 1.0 References: <836025199.2014747.1673889335246@mail.virginmedia.com> <20240220070505.fd6jfbcdldieqv7u@chazelas.org> <20240220193911.avnmcqfliwltkj5m@chazelas.org> <20240221194534.o2mufin7orng6ttg@chazelas.org> <20240221202150.tccftcqbxqqexq4x@chazelas.org> <20240222072313.7woy5vxvt4fbxyhj@chazelas.org> <20240222075528.eruaoosiuhmcrdsy@chazelas.org> In-Reply-To: From: Bart Schaefer Date: Thu, 22 Feb 2024 14:31:12 -0800 Message-ID: Subject: Re: Metafication in error messages (Was: [PATCH] unmetafy Re: $var not expanded in ${x?$var}) To: zsh workers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52580 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Thu, Feb 22, 2024 at 9:07=E2=80=AFAM Bart Schaefer wrote: > > However, per commentary in the other thread, I'm going to recommend > against using this patch in the first place. We need to rethink this > whole approach. On Thu, Feb 22, 2024 at 9:02=E2=80=AFAM Bart Schaefer wrote: > > Actually the string is NOT really expected to be metafied ... in fact, %l allocates space for it to be metafied during output. > ... usually it's a plain string hardwired in the calling code Curiously, the only existing uses of %l are for strings that came from user input (arithmetic or a history reference) so they're almost certainly already metafied. So ... one possible approach is to declare that %l is the way to produce "raw" output, and have it perform the unmetafy() + fwrite(). However, it's not clear to me that's preferred in Stephane's examples like this one: > > $ printf '%d\n' $'1+|a\x83 c' > > zsh: bad math expression: operand expected at `|a^@c' Do we really want to "see" a raw \x83 there? No one would intentionally use a math syntax error e.g. to produce terminal control sequences. > the caller actually should have the responsibility for unmetafy. Another possibility therefore is to to have %l do raw output but NOT unmetafy(), so the caller would need to either unmetafy() and pass a length, or nicedup() the string when that was the desired output (which handles the unmetafy() internally, and nul-terminates). The final option would be to leave %l alone and add %S with a length argument ... but I don't see that as much better than the foregoing, given the very limited use of %l so far. Opinions?