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 C144921F4B for ; Tue, 20 Feb 2024 08:05:52 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708412752; b=ay8JqGH5aoeu3XGFs5p1PBnEnVRlGegJ4xhvSwH2SP8/KORIRP8RJlbffwoSMK0nM7ojcpeXfv Qe05TUM5rl3/ceR/CpMR6sRR1BaO5mfzuvQmDexkoxqHk/ooQ/DlhlBQTaUq3EvIFqoD2bFJsd tkp6ShoIhWKdQi7JzzuPJsqs1T9PWjUOPJxQsYt9hTA7eH+5prQh+b72jxLdXIp5Jy67LZhq0Z HwdXRp7nb6fE6aJLhH+bHt5XYxWqEnvGXUW/XTnAF+baGKhb5RAQcOpoeLCvcdiJPfjRWyy3xM RK6QvbJIWUgJGt6zXWiMr8CjiYWDDFHLlrMpxPr8DAhPZg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay9-d.mail.gandi.net) smtp.remote-ip=217.70.183.199; 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=1708412752; bh=mavR05dVpsiO6sbpoaCqN2ZQBlPF8gtQ352t/NK5PR8=; 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=RaoWt4COsaLLxhXOnIq8a/ITlZqoyFl4H7B+cjTAGp9mhccbTcmTgMY6f+GfeoVHqK65gpqdHs MfKkwtG3O+cdUAE+onLp+0upiQ6lJzBUhbjqhrkBiRuHZTiInY8g+9hVHVofmBUUsQNJ0Vex76 eeWYKcCgnXg1waSShn1xEISOY8y5CZSf9YFZoZBdiHyBtSWjzYOWW6gsFlE9yr7RvBKGtBJINd 73MtdwuYfL0WJH8PmDI7AshP7c4eD9yp+QTBo0kKP/jdmhorL3cdvxTEflMaiXmmi/ArPcr3jL kNgN3rXAmUtD6fqJwugqsBvXTF4FL150dFPuLLX5ySz9lA==; 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=I08xqBs89dgh4nfEzfW4lLS0KUxT/+PspKy/HMw9wOA=; b=cs3n96t5Vjl4GRhmD94+J1NQmW rZN8vclB2oe0RjU7FdGPAAK0855fm6bY/LDJ3OWoJZ41PkuJohzVssJ3V23xuHoT8Vl5C8RUkUrc8 3u/7XcKZYK/II7hfnWI0KK7JTTP9ouw6XDQmxozDpvpjQzoqMLlNCB8UsN8pyL5LEHTsYn3ZLbvj2 moGSO5ipJP6M9MuOsIHk2wilNq8UAercg6eEdx7kTG2DrWP1ThseH5wX6bARwUy4u10NKsWFeGmHH pzXfm21nu5ssCRbizSL9p10tGYAXCzTXHQFRMd69hOeWkXkkKss81bfhoczaLXEZr/Z5dTtCfbETt BiBNf5Nw==; Received: by zero.zsh.org with local id 1rcKCN-0009c5-Tx; Tue, 20 Feb 2024 07:05:51 +0000 Authentication-Results: zsh.org; iprev=pass (relay9-d.mail.gandi.net) smtp.remote-ip=217.70.183.199; dmarc=none header.from=chazelas.org; arc=none Received: from relay9-d.mail.gandi.net ([217.70.183.199]:54629) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rcKBf-0009Gx-Pp; Tue, 20 Feb 2024 07:05:08 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 83DE9FF802; Tue, 20 Feb 2024 07:05:06 +0000 (UTC) Date: Tue, 20 Feb 2024 07:05:05 +0000 From: Stephane Chazelas To: Peter Stephenson Cc: zsh workers Subject: Re: $var not expanded in ${x?$var} Message-ID: <20240220070505.fd6jfbcdldieqv7u@chazelas.org> Mail-Followup-To: Peter Stephenson , zsh workers References: <20230113080246.nghigc4givvaomve@chazelas.org> <836025199.2014747.1673889335246@mail.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <836025199.2014747.1673889335246@mail.virginmedia.com> X-GND-Sasl: stephane@chazelas.org X-Seq: 52560 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: 2023-01-16 17:15:35 +0000, Peter Stephenson: > > On 13/01/2023 08:02 Stephane Chazelas wrote: > > > > $ zsh -c 'echo ${1?$USERNAME}' > > zsh:1: 1: $USERNAME > > > > No quote removal either: > > > > $ zsh -c 'echo ${1?"x"}' > > zsh:1: 1: "x" > > > > Doc says: > > > > > In any of the above expressions that test a variable and substitute an > > > alternate WORD, note that you can use standard shell quoting in the WORD > > > value to selectively override the splitting done by the SH_WORD_SPLIT > > > option and the = flag, but not splitting by the s:STRING: flag. > > In fact the shell does not "substitute an alternate WORD" here, it > just prints it out, but the difference is easy to miss and expanding it > seems the right thing to do from other points of view, so I've noted it > in the doc. [...] Thanks. $ echo ${1?$'a\nb'} zsh: 1: a\nb $ print -Prv err '%F{red}BAD%f' $ a=${1?$err} zsh: 1: ^[[31mBAD^[[39m That transformation of newline into \n and other nicezputs'ness seems undesirable to me though. It doesn't seem unreasonable for someone to want to provide a multiline error message or one with terminal escape sequences. See for instance https://unix.stackexchange.com/questions/769679/bash-parameter-substitution-with-multi-line-error-message AFAICT, except for bash doing the IFS-split + join, all other shells send the expansion verbatim to stderr. -- Stephane