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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2344 invoked from network); 29 Jan 2021 15:33:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Jan 2021 15:33:48 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1611934428; b=zYiNOlQw+Jj0Rlpg5bxWwO/FWsP5vmDWbDN8SOLkx4qCD86DgDhpx3pT2JmTDlkd+NaR/uIPXA rma+K49JYTCmTUp3hy5EjEUnSOknGEsnZB14DA+/glQ4dB3cpxOetLqIgpJp6fl9RIY/AILoor Bn9dKtX8w5iJUup5LlqOSU6YKQzhV/138fFTcCyGm1JkWliiR2bq6PbkrXYcyh+v9poqojPBJ8 GCtMwVMCZQBx7Gfm+L1Jz9VoaVXlyAwH8qTeFOe5rEBruMVHfRGKHG+jariyuzCdACcafF+A6p p7kINN4kkImp0cxa3tXF11Y3MwK6JxTWNOcVJ3zgBfmJOQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f46.google.com) smtp.remote-ip=209.85.166.46; dkim=pass header.d=gmail.com header.s=20161025 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-20200801; t=1611934428; bh=+WlifwVwusC6TZ/SX3vvSHgumK2GGt3qhejLf6JJ51c=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=QdYfTAn9NMrKb/pt6w1tEr/EEAYhnA1KstjzHLxkFxcI2G1pHT5YrRPFZj1If0FVE1Y3ygkV9t X20/oR3cC81rY1jGNj6keI4gK7Fj9kcqXkjX8nWSCxPnQNdmJAjQ9coqbmv9xq61sbsoLDLLIb axii9Uq2m/8XV6Lt58sHEZ+NhorhKMe05pFPw5uiM0woZ3rxdtsI3VSEKF05SPW+pdb5KRbbyT DsU49jozrh/eWLn2MB6qeMmgl9AXKPqKWmkxb/M9a/cDpMZNbYvfyRzvZkmFLCNaTC1Zld1fiF Twr4u+UPe9YdfSXMjDDVj4ClWik+s2cZRuEETB9vVWjZVA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References: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=zGmgifoKuc47qxNsmqA6ZNas7YuPavKyKZPxlK2uLUA=; b=pzmx9N+Mj/kb8nntsZP4EHPs4I KIeLaZdD+y1/qsLAjh9YDwiFOBehNVfoquzzok2Op6NQLGhCGH+9D12qokxUhsDzliXXViQRwjMmV 9g7C0M7YnThmNppUA+9ckoYVVmbtLdT99s6RemTSm7fH1NCv03Cf+eBckRFpMCW9mn7xrLChWPRkV X8Zvlje2ygSFU9X9lZLAT0iR82jb/vc2BdkHi4rt0MlokHAenjoU6p+1bxdY3tw6vBR9KuRQ4hc9Z fIuB0fdrrOrADP6N02kY2Vm4I9ulbZQSnLAORml0au2gPiXvYT9qQtbzrfkPLXzFgolryMOon84/q IYBe1blg==; Received: from authenticated user by zero.zsh.org with local id 1l5VmO-00030M-0h; Fri, 29 Jan 2021 15:33:48 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f46.google.com) smtp.remote-ip=209.85.166.46; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f46.google.com ([209.85.166.46]:40308) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1l5Vlt-0002cu-UQ; Fri, 29 Jan 2021 15:33:18 +0000 Received: by mail-io1-f46.google.com with SMTP id n2so9675915iom.7 for ; Fri, 29 Jan 2021 07:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zGmgifoKuc47qxNsmqA6ZNas7YuPavKyKZPxlK2uLUA=; b=hujggVpdTTFx3yfmBDLRhKYKrMQTyBlbCZSw2NKb51IfHMrP3ILt9By1CywwJhPGV1 zBOxHAUDne9hWqQQEci+UztJsKK60gj7OkHHJWu1X6Ujam/wSU00uuoCebZHvvcZ5Dgl NMmhes9MlO6GXhpYI9WRLWN7Fe48NCxfrL7oSW5V6FK8/8aba1iBEdAXS34FiCyEgrub HKFk5DdHsVkr1tjiYyGrAe9cs+xZVyAf+5+bHeIYP63VRhgw6/uRLZr+SrXvkD8cTW9x rCbOUBE459nLxQb7EDmoQD6cyYsRId/XR516dwvjWwPLUyKbaul0Z45ljPkg1JjZFdcE ET9g== 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:cc; bh=zGmgifoKuc47qxNsmqA6ZNas7YuPavKyKZPxlK2uLUA=; b=N79FEwgx+SXvpqjZChqEXNrGn5nGcr0q9ikje1XhZg7MisK6NthTyD+B0r7MjOItvh +1Axwbv1VoaQ1s+yAjlVYsTYh4CrhpW88M2a8iv4pxJqBg7SWC7JClRJKmZZxsP5w/5D 1vHNnPmJ24Cz8d+nmHyVEEOz2Vlw7LebmPB6UW2I9ZWqDiw1deSrHQbUK9LEqDVSEW7R m8B+VNNGqFv5TyaxRfFUThs9iIqgszbcx82Q1X2wO6LNlrGujc7BAmpcMnQLaPpgQS4o EJ8cS7T9mFHEX81RpGfWnOTu/z6dQKb4R9vIABQP6Byp8Rhv1+mDczPK1F9y7opWoRWU 3zUQ== X-Gm-Message-State: AOAM530N2Wg1v6m2ofA7PTPJlpTXziidUyKTamp1nQXuPs/HbaRNMSJ4 QmQDsnvZQaj4GRsA4gU1mqwATR9CcziWeGOlayg= X-Google-Smtp-Source: ABdhPJzbMyXXqocU+/5QmbntXMYMeACGB+1t0JlA3ou1mpo6IsS+nTBR/2xQfqHHNrYzDJejoqwNxd28IQbZlXUxdaU= X-Received: by 2002:a05:6638:229b:: with SMTP id y27mr4141479jas.136.1611934396376; Fri, 29 Jan 2021 07:33:16 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Fri, 29 Jan 2021 16:33:04 +0100 Message-ID: Subject: Re: (N) defaults to whole directory listing To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 26435 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: Archived-At: On Fri, Jan 29, 2021 at 4:24 PM Ray Andrews wrote: > > Is this really what we want? > > $ ls -1 no_such_file > ls: cannot access 'no_such_file': No such file or directory > > $ ls -1 no_such_file 2> /dev/null > > $ ls -1 no_such_file(N) > aaa > aa-messagefunctions > aliases > aliases,1,remove _find_match > aliases,2,STARTCOM > ... > > .... lists the whole directory. It's not exactly what one might > expect. I can see that if the argument 'disappears' entirely then > 'ls' thinks 'ls *' but shouldn't 'ls' be in a 'not found' condition > rather than a 'list all' condition? `ls` without arguments lists files in the current directory. This is mandated by POSIX and what everyone expects. `no_such_file(N)` expands to nothing if there is no file named `no_such_file` in the current directory. This is in line with the zsh documentation and what everyone expects. If your examples aren't artificial but really show what you are trying to do, you can do it like this: print -rC1 -- no_such_file(N) This will print `no_such_file` if such file exists and will do nothing otherwise. If you really need that `ls` call (perhaps because you are passing some flags to it), you can do this: ( ls -1 no_such_file(#q) ) 2>/dev/null This does the same as above but about 1000 times slower and returns an error if the file doesn't exist. You can also use an explicit condition: if [[ -e no_such_file ]]; then ls -1 no_such_file fi Roman.