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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 2D9C12470E for ; Thu, 7 Mar 2024 09:26:41 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709800001; b=LAyCdgFcPSS7YeXr981hj5r5VUjLFX5FY7qDwK4exUOZqG7c2DAXshKv2m/bTYiJymPNT8u/NR MEjXk5lYQXQgCbf+fG6yis4R70qmvfXdf5hPXNLkKvZi/IdVX61Yssa2027fdSU1e0fciqdRbR pnhEjKoXlc9ZcT64PmZmsccVLhCK09XgHwdx3FVtutfsjnCrt6FbCkgnJQGv3o2Yp3BVEj6+7X z4SwX/Kck6Cbr0UbinNh4wHBupXfLzt9IxT87zyi377R78DSwXGgrTleOkzlZU+I5d0DpB7LcX FfCpg8sY+1p2uh8XrMJhUQ7C27ptJXFBKso2yUX2ZlX6Sg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=gmail.com header.s=20230601 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=1709800001; bh=itIN+MAQtrYzTf6G+ycVopFDHieaddfoJ0noc9o4i2g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=ZXCa0HBjyqEBklew7OxDTUnJqRuki+v15SEikjfbL3taMJKC7Vugt4qbpG8RBeKxkgREFpV7QJ F+guLmts/c/K1th/KAnF6JmOKUyZgG8+Uye1IKEPfwKDTNQqxoqpbDReSsCNWerP2pK4pHqYxd MNXYuoIKY+8gNsKtA/lG6VSDrDS24BK5CNfLWugW5JILx3hBFnHZX5ATO5qWGLryMik8ktgp9h 0DKUZl1ytjWzLqSIQ+QwFzTsvxQV9RswvhH9tjM/i64G3ISlo8ANC4sqsUDNynzHTvYCdJKOX7 Q7/fz9u9u/GZlqH+uxgDk1Y5PqWr8GwT3Idkageoq3Z9Iw==; 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:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1vepDdC7vUPpZXHwmAezg7oP1jIw9XWdcGMlhVdnE0U=; b=HCquXKai3SzWdyTj/N1qVml1GK SzmKfixf6/y2CpQOdGGQSdIoOH86sCRsuYSMhL53e5UhWn8b2//a0Xwh/sO6WUe6wIw6R/ZnZWR4W DsbkjOB/Ae9Jpn936b490L+tOfhWdNpuB8OJIT9Pdt2PB/Moq7zvCsd8S/FGg7bHOfF1FDBfa5irR VHiQliIeh8ydQI/LdvSh2cfSq0SZW1w9CZvgF79i1VKO3Bc8f6/CEGjxl/eQyWJh4QqY70+1j1ZZE b+rI4wrqFn3qgL+Qn9yIJffBlb8kTs5YCT5bTN/rVXne6y12N2QRR7ZgOYNJIQaZkRnPkbp70cgOI 4LssbBDg==; Received: by zero.zsh.org with local id 1ri95N-000AQz-KW; Thu, 07 Mar 2024 08:26:41 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f51.google.com ([209.85.218.51]:47373) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ri952-000A1n-Tr; Thu, 07 Mar 2024 08:26:23 +0000 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a450bedffdfso78968966b.3; Thu, 07 Mar 2024 00:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709799980; x=1710404780; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1vepDdC7vUPpZXHwmAezg7oP1jIw9XWdcGMlhVdnE0U=; b=WGH6mxC1yP0Quk9l86pS47TcgDLUjSQieATPWA+g3sdSqoWgArO7zvwqhdUKflP0Ps O1BdYG4EZXJrc/1A93CDr5+5VT82ij2Uu/A3r3/5jHafOILRpYRJK8PIgiiIj/GMIUfA zn5CjypVfRzw5zQ8jzJaf4/lU1PAKjaNbrqCMvl2KyUBrUnbikpm8Auc3YUUi3QkKNsy AmhKrmsZ2AoLP0wQ9N3qKNOuLIdg+tQAP+7jllTADxfRdMpiIbn/PJL83Bj2pB6muZYM SI05WzT6lBzgpz+xtXKFZU44QsItEXrr4hhMd4LqIdCw3jaoC7sVC6+/A9H9XlCg31+I +LtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709799980; x=1710404780; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1vepDdC7vUPpZXHwmAezg7oP1jIw9XWdcGMlhVdnE0U=; b=eLfyg5lt3FOVj+Co76IxGay21j+8Z/YJ7TAEhUQEN55uh7Azj+Mn4jHZmJY97lzjPl 6Mm/MmhKuuuBtZeD5oqufo2jtndZLtZ8ePCXpRv8e5pM82MwwUZSVREK90kVzGj6ZStI 5F8SgFt5uf0CyUTu6xJqLghuRcN4D22Pwh3FIgmWZNlURundhMM5LBCV12c/TT8ki2R+ 1cCyjEFIBekJ/eNeBy8OlJ6oYsk0PBSvoxa8A4Io5s8P12za4MmKt218BOzbMxABMtyM Q0FUW1xsK2x/O1w32t1d764OkGLzeup8EFB2cyxhdtFI4Lvl2SoOXX4R/8m8j5jZf66K bzHw== X-Gm-Message-State: AOJu0YyCfIaOgZ+BIFtcDUdmyg93L7ktm7vRXW//ics1rOWfgprAiXxu et5hFxyWoj1djrtuz9/zTXqNKFNN52glJrBhmPpjDQf9IKi7zzQTkZRRJJd5tMpuC8GtFbYycjW +QuzA2Qj0fi8aAzqTZ4VB1KeHNaxN1/Nc X-Google-Smtp-Source: AGHT+IHx1RDwudgMUpySuYcN5wAPkzEUNCAFbc9x8wsGKa9QnY/HdNPnK4lFoT2yRz/1n8/5cgjgnJU+XliK3Rf3x1I= X-Received: by 2002:a17:906:355a:b0:a43:f1d9:400a with SMTP id s26-20020a170906355a00b00a43f1d9400amr12789356eja.26.1709799979774; Thu, 07 Mar 2024 00:26:19 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:7208:5351:b0:7f:2ef1:5159 with HTTP; Thu, 7 Mar 2024 00:26:18 -0800 (PST) In-Reply-To: References: <20240305065606.ccr2ieheahslcpye@chazelas.org> <20240306175711.t3uz2sery3b6tbjw@chazelas.org> From: Mikael Magnusson Date: Thu, 7 Mar 2024 09:26:18 +0100 Message-ID: Subject: Re: [PATCH?] Nofork and removing newlines To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52708 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 3/7/24, Lawrence Vel=C3=A1zquez wrote: > On Wed, Mar 6, 2024, at 5:22 PM, Mikael Magnusson wrote: >> "${ foo}" and ${ foo} having the same wordsplitting behavior but only >> differing in stripping newlines feels a bit magical and weird. > > I agree. Personally, I'm always surprised when quoting does anything > other than suppress splitting, globbing, and special characters in > patterns. For instance, I can never remember this pitfall mentioned > in workers/52666, even though (I think) I understand why it happens: > > % print ${:-{}x} > {}x > % print "${:-{}x}" > {x} This is not really an effect of quoting per se, really it's just luck that the unquoted form works. You'll notice that if you try print "${:-}x}" without the quotes it will simply fail. Your example only happens to pass the parsing stage because the braces are balanced which they have no inherent reason to do in what is supposedly a string literal. Because the parser "knows" about the balanced braces in the unquoted case, it skips past the first } for closing the ${, but in the quoted form the { is not special in any way, so the first } does match the ${, and then the second } is just a literal } which is then printed after the x. The correct way to write it in both cases would be: % print ${:-\{\}x} {}x % print "${:-{\}x}" {}x (you can \escape the { inside the quotes too if you want, but it has no effect on the result). --=20 Mikael Magnusson