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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24475 invoked from network); 5 Dec 2022 02:53:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Dec 2022 02:53:53 -0000 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:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=x+INUP5wTtp5Ak9dKONfgnnPPPR0TGwGPyQy39XnyL4=; b=AQJXzXMNy9OnUWtk+hA1314L7c k2I/Cvk0Wbntv4vP7vlnpxFDWyCsLQRq4fQKEDFLIorBiE96nwCGFLVkG8eiO+JqnB2QwTNYvxp5m gZk6pT4zPz95nmCrolOnc/cBSyGojpLeQKeKYRGdkiaTGIpqhUq+iN/1HCr3rok3qA6QxJUAWKimC USCmwIKVm1tYdunk7HkRuRD6wxfy/vmJSkYfWaGDE1WFlCOoGGNzHnY5kbNC/XTTrKUULjIO4uzSJ R0Ik7K2j/ZevFk3hBmQ5emJneL7G5//SE+msDPFkHctGqd56ksFsdJRNkhOW0eJ8B9nNO+KPJbmZ6 upBwsn2Q==; Received: by zero.zsh.org with local id 1p21c9-000CDL-8L; Mon, 05 Dec 2022 02:53:53 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1p21bU-000BWN-6b; Mon, 05 Dec 2022 02:53:12 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 4AC3227C0054; Sun, 4 Dec 2022 21:53:08 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute1.internal (MEProxy); Sun, 04 Dec 2022 21:53:08 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudefgdehvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreerjeenucfhrhhomhepnfgrfihr vghntggvucggvghljoiiqhhuvgiiuceolhgrrhhrhihvseiishhhrdhorhhgqeenucggtf frrghtthgvrhhnpefhtedthfelhedtvefgiefhtefftdegudffteeiheejtdevudeiheeu kefgffetffenucffohhmrghinhepshhouhhrtggvfhhorhhgvgdrihhonecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhmvghs mhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvdejfe ekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0BADE31A0063; Sun, 4 Dec 2022 21:53:07 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-Id: <63ae2364-1bba-405d-a1e6-4813df512340@app.fastmail.com> In-Reply-To: <9d81fc7d-aa60-9b6a-47df-6fc677b933f9@eastlink.ca> References: <9d81fc7d-aa60-9b6a-47df-6fc677b933f9@eastlink.ca> Date: Sun, 04 Dec 2022 21:52:06 -0500 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Ray Andrews" Cc: zsh-users@zsh.org Subject: Re: trivial question Content-Type: text/plain X-Seq: 28477 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Sun, Dec 4, 2022, at 9:05 PM, Ray Andrews wrote: > Running this: > > var=( "now is" "the time" "for all good" "men to" ) > > echo var[2] ain\'t nothing > echo var2] ain\'t nothing > echo "var[2]" > echo $var[2] > > ... I get this: > > 4 /aWorking/Zsh/Source/Wk 0 $ . test1 > ain't nothing > var2] ain't nothing > var[2] > the time > > > ... It hardly matters but I'm curious that 'var[2]' without the dollar > sign evaluates to nothing at all. In this context, "var[2]" is recognized as a valid glob, and zsh attempts to generate filenames with it. If a file or directory matches, its name is inserted as usual. % cat foo.zsh var=('now is' 'the time' 'for all good' 'men to') printf '<%s>' var[2] ain\'t nothing echo % : >var2 % zsh foo.zsh If no file or directory matches, zsh generates an error by default. % rm var2 % zsh foo.zsh foo.zsh:3: no matches found: var[2] If NULL_GLOB is enabled (which you presumably have done), the failed glob expands to nothing instead. % zsh -o NULL_GLOB foo.zsh > I have zero need for it to do > otherwise still I'm mildly expecting it to just end up as a plain string This happens if NOMATCH is disabled. % zsh +o NOMATCH foo.zsh It is also the default behavior for failed globs in other shells. > the same way 'var2]' does. The latter is not a valid glob, so zsh does not attempt to generate filenames with it. It is just passed as a literal argument. > Seems strange that it evaporates entirely. This is all explained in the manual. https://zsh.sourceforge.io/Doc/Release/Expansion.html#Filename-Generation -- vq