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 23568 invoked from network); 1 Sep 2021 14:54:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Sep 2021 14:54:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1630508042; b=JzCQIcU61j8lONib6xqfj8qMWoQrKl/QLSrMrJdeer2k7P7fFX/6isMk6Hlt2IGN6TS9Z+BA3i uay/oM+W5LB/Rog4Ljxr8fhj6zplENMnjXZTA4VbCDbqDMdIl6wo9pgxLWeLYso8YnbFDktlZi QOAZOPIYjf7E8YvCY+TRsSLeJjUm9UbGFVAsFK+z20U98x9aD9100YUzR5SY+0LcKV+fDCfJfc JwQY5ggn+zJWTWHdfOfO3GCAQWREjwi7pC01nwErenY3n5C9R8xIbioytuHUgG74yqhQ4ReDl1 d4X1d6eTiLUKzOOtn+dEGmxqUCSFLi4ffT1PD8Pbs62h+w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; 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=1630508042; bh=izCXmGgmGbtY2/qZfXSbtqBg/nZGYIWD6SmhpLsjBp8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=cEoN/hbYVsFiL6bUst3MvySd+dS2Capie65/7CQ0laa8tgCfFYBZr+zjVvLLHSue89U5DgpxZB 1RTQg1nNzNJ3E8IR/n2FzaC06Mlw7ldq1tKB1cH3/fh5zG9HDKrX4FV/J1VqggmjGOkLA7CjD0 iY5ZLW1RpnZtnS1wILL6eNRiV1QpzCEROLhNLML5fonk7hlombm24Lh32CYxz+fH8xSTChRm6/ Ylh4T+ewpkEboLxt6N6QrX4ySOok01NcHqYQl/4fjS4r0DS98XUad1uDZ7BNbQre2NaSr4Gctb +X5QR/glSB4LXv3MDcJyghma7nm7TIAxMY0BFGct3r05kA==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=NUfG4HyYOn3JMHu5R+/wNB+K20n9joLJeQTtnBsQzkA=; b=HsQYQE1HrXLzfv1wPJAMAuS5Fy N+tM76Z4QxKLKT2g0Ir+VmyOaHxMFNCZvMhv3IU88lSA4UEwX3bN6Dkm1jzNkIiYL30B5+QKzG4+v nC3Cc1HE4ILst9HNkwEiLcFY0cN9CMWMf5tJalMqITKFS4P/shrUSgvZv/Kso+oMzvtDCsI5DjbDF l2pyy8ewhZ+mMnEQVvKk4vVmA/dB1lsSIg1w90eqR1GIoexlYT9jQinzWL464UafvoJZ6S69pNWWs IcP+75evqS/YqiNBZzEPDhLyzC5+7QF9jak6uJniLE8EHvwWRUlo+jVn8H5e39j0bCMs66snJIGA7 NInRV9lQ==; Received: from authenticated user by zero.zsh.org with local id 1mLRcn-000O60-LR; Wed, 01 Sep 2021 14:54:01 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f53.google.com ([209.85.218.53]:36627) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mLRcX-000NoF-FK; Wed, 01 Sep 2021 14:53:46 +0000 Received: by mail-ej1-f53.google.com with SMTP id bt14so7321237ejb.3 for ; Wed, 01 Sep 2021 07:53:45 -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; bh=NUfG4HyYOn3JMHu5R+/wNB+K20n9joLJeQTtnBsQzkA=; b=qM+rxtRfYZAlHYoeQ0ryDYVMH1JXG7UgWjlDgh4Gag5a2AGWFaaZiPbmYCC33x9HHM 5S0reMZpV/A09kcbz9gQ2jMOk9H/sVlaRHE7xNyuy6sFsnE7M0qHgvLduVRrqvuyBGIi ognagfVwmmbI7OQTgeQHaMKJpaaS8YHxr9zy4+nwCsB/XFTmTdkxrE+P9kY4rOS5yc98 7H1ZW2OOIeEBmBPuF2kD3xdkq6BxYN4/lQ6T3mZ/JUVN3aMKuxOwSyI5vNWz1PKjE27G Ce4c/IZZ5vTpgB053QREB0aASowE6ZieLd9yfPHXErZUoaquMPqAttWfEW6iFW+f/vJp rLrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=NUfG4HyYOn3JMHu5R+/wNB+K20n9joLJeQTtnBsQzkA=; b=YF69ijQC7qBj2/pTr4q291a6z/b9WPrWdAPj6EoZmccnr/H+FTWz6V+4cEuA03gqdK MOj768xqjPCA/7ALHaFj99unKgjlmEoPU86FBxM+w+uFHx3xLIj30Tpq/sZE96TXVnSX k1RNZaPAu6xBz8/pZ5A5o9vqr9AMMRbk1BivZrsxXvDrtZKus2+7wtIGezUPepWuhNZw c8Ken/xNHvqQfbWT0sTg1Mb+wCquIRAe376WJA2RhfWSrrxOo6C318ZfPdfzMH3kicpc sbT2AB6eE0/OSrC6+D1q+GV6CG6GrO1+bP2Bt9wk2NH45aJ3CmCaWsKWw9uWemcKlIB5 SxEw== X-Gm-Message-State: AOAM531Y182hGptniUWaYZ6XN9Ax4PFQ8kBKVLM0hktVQASZRlW8zZDb /pjqXReo0YjG6dV4Oo9+9vor8DVcD+98MVbFPysBTaLt898= X-Google-Smtp-Source: ABdhPJwPqycHLmvJq1Dtb67hOVQ8NV60YQPca5dGOQ6NVh7Cd48/M8ZM4iNaHdn5wWwK9Cj46KuSGwP2gUVFOLIhs0I= X-Received: by 2002:a17:906:d9dc:: with SMTP id qk28mr37492287ejb.359.1630508025089; Wed, 01 Sep 2021 07:53:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shineru Date: Thu, 2 Sep 2021 00:53:33 +1000 Message-ID: Subject: Re: tr [:lower:] To: Shineru , zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000a390a405caf03b1d" X-Seq: 49352 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: --000000000000a390a405caf03b1d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks! =D0=B2=D1=82, 31 =D0=B0=D0=B2=D0=B3. 2021 =D0=B3. =D0=B2 11:39, Phil Pennoc= k < zsh-workers+phil.pennock@spodhuis.org>: > On 2021-08-31 at 11:04 +1000, Shineru wrote: > > zsh 5.8.1. Arch GNU/Linux > > > > zsh: echo "hello" | tr [:lower:] [:upper:] > > zsh: no matches found: [:lower:] > > setopt nonomatch > or: unsetopt nomatch > but: both of these are dangerous, because there's a real quoting issue > here. > > % touch l p > % echo "hello" | tr [:lower:] [:upper:] > heppo > bash$ echo "hello" | tr [:lower:] [:upper:] > heppo > > Without quoting, > [:lower:] matches any of: l o w e r : > [:upper:] matches any of: u p e r : > so the globbing turns the pipeline into: > echo "hello" | tr "l" "p" > > By default, zsh complains about unmatched patterns, rather than letting > them fall through silently. Falling through leads to this sort of > "foot-gun" construct, where shells encourage you to do something which > "only works as long as X is not true", instead of having reliable code. > > So you want, for safety, in any shell which resembles POSIX at all: > > echo 'hello' | tr '[:lower:]' '[:upper:]' > > (This probably belongs on zsh-users.) > > -Phil > --000000000000a390a405caf03b1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks!

=D0=B2=D1=82, 31 =D0=B0=D0=B2=D0=B3. 2021 =D0= =B3. =D0=B2 11:39, Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>:
On 2021-08-31 at 11:04 += 1000, Shineru wrote:
> zsh 5.8.1. Arch GNU/Linux
>
> zsh: echo "hello" | tr [:lower:] [:upper:]
> zsh: no matches found: [:lower:]

setopt nonomatch
or:=C2=A0 unsetopt nomatch
but: both of these are dangerous, because there's a real quoting issue<= br> here.

% touch l p
% echo "hello" | tr [:lower:] [:upper:]
heppo
bash$ echo "hello" | tr [:lower:] [:upper:]
heppo

Without quoting,
=C2=A0 [:lower:] matches any of: l o w e r :
=C2=A0 [:upper:] matches any of: u p e r :
so the globbing turns the pipeline into:
=C2=A0 echo "hello" | tr "l" "p"

By default, zsh complains about unmatched patterns, rather than letting
them fall through silently.=C2=A0 Falling through leads to this sort of
"foot-gun" construct, where shells encourage you to do something = which
"only works as long as X is not true", instead of having reliable= code.

So you want, for safety, in any shell which resembles POSIX at all:

=C2=A0 echo 'hello' | tr '[:lower:]' '[:upper:]'
(This probably belongs on zsh-users.)

-Phil
--000000000000a390a405caf03b1d--