From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 22 18:48:39 2024 Received: (at submit) by debbugs.gnu.org; 22 Jan 2024 23:48:39 +0000 Received: from localhost ([127.0.0.1]:41970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS41v-0003ty-4I for submit@debbugs.gnu.org; Mon, 22 Jan 2024 18:48:39 -0500 Received: from lists.gnu.org ([2001:470:142::17]:55972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS41s-0003t9-E5 for submit@debbugs.gnu.org; Mon, 22 Jan 2024 18:48:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rS41i-0003LW-7h for bug-grep@gnu.org; Mon, 22 Jan 2024 18:48:26 -0500 Received: from frenzy.freefriends.org ([198.99.81.75] helo=freefriends.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rS41g-0006HA-Jh for bug-grep@gnu.org; Mon, 22 Jan 2024 18:48:25 -0500 X-Envelope-From: karl@freefriends.org X-Envelope-To: Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 40MNmLFp005478 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Jan 2024 16:48:21 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 40MNmLBV005476; Mon, 22 Jan 2024 16:48:21 -0700 Date: Mon, 22 Jan 2024 16:48:21 -0700 Message-Id: <202401222348.40MNmLBV005476@freefriends.org> From: Karl Berry To: bug-grep@gnu.org Subject: warning if --exclude-dir arg contains /? Received-SPF: pass client-ip=198.99.81.75; envelope-from=karl@freefriends.org; helo=freefriends.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Would it be crazy for grep --exclude-dir=foo/bar to give a warning? Since, as I understand it, any non-trailing / in the arg can never match since the arg is matched against the basename. This came up when I ran grep -r --exclude="t/*.dir", thinking it would exclude all the test output directories. Nope ... --thanks, karl. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 23 00:37:42 2024 Received: (at 68666) by debbugs.gnu.org; 23 Jan 2024 05:37:42 +0000 Received: from localhost ([127.0.0.1]:42061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS9Ti-0004Zj-79 for submit@debbugs.gnu.org; Tue, 23 Jan 2024 00:37:42 -0500 Received: from mail.cs.ucla.edu ([131.179.128.66]:43268) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS9Td-0004ZQ-JI for 68666@debbugs.gnu.org; Tue, 23 Jan 2024 00:37:41 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id DE78C3C011BD7; Mon, 22 Jan 2024 21:37:26 -0800 (PST) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id d0eOUgmmePpb; Mon, 22 Jan 2024 21:37:26 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id A10343C00E413; Mon, 22 Jan 2024 21:37:26 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu A10343C00E413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1705988246; bh=0UqtHHMb/4vUYTHy1r3vwuwFwYKy5d88VklapLTa1yg=; h=Message-ID:Date:MIME-Version:To:From; b=VMZOGDvxFuaUTBxYJ+Royt3NySyxL4TY7xPVeuB/M1FrD+5rpBbNo29SGBPL2OsuZ NLquQVu3bNeXiCofZsTsp7WnbA0TaI2uEn7Ijzko5AQyviv7QHMLCW4KDvsS2ClcNV BHFPC9iwZ5+9BfyjMgr2pzXLIyoKcCHPgIhZ0mTLRq56nbSbGeqUCMyd+56I2qPth8 Viz3X0Bc4yUITHp2eHZ/vFW6Jk1Nf3i5pKwYREJF1DNR6jEwWD2kGwMm477hPUT9cQ +XsmPKs5hICuoCEjm6nUe5gNWdIaA/rR0eRkyBS8FwVDUz8zdPB63OKXlPJ1GWliAE TrRevMTBa6UOg== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id P8jtwLIEIvvr; Mon, 22 Jan 2024 21:37:26 -0800 (PST) Received: from [192.168.254.12] (unknown [47.148.192.211]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 7F7DE3C011BD7; Mon, 22 Jan 2024 21:37:26 -0800 (PST) Message-ID: <59cb3b5d-8419-43f6-9ec0-31565b8e8a5e@cs.ucla.edu> Date: Mon, 22 Jan 2024 21:37:26 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#68666: warning if --exclude-dir arg contains /? Content-Language: en-US To: Karl Berry , 68666@debbugs.gnu.org References: <202401222348.40MNmLBV005476@freefriends.org> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <202401222348.40MNmLBV005476@freefriends.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68666 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2024-01-22 15:48, Karl Berry wrote: > Would it be crazy for grep --exclude-dir=foo/bar to give a warning? > > Since, as I understand it, any non-trailing / in the arg can never match > since the arg is matched against the basename. That's not quite true, as it can match command-line arguments. For example: $ grep -rl . lib/* | grep '^lib/unictype/\.gitignore$' lib/unictype/.gitignore $ grep --exclude-dir=lib/unictype -rl . lib/* | grep '^lib/unictype/\.gitignore$' $ It should be possible to give useful warnings in some cases, though. It's too bad the rules are so complicated - that's partly my fault, as the various options were added at different times and I didn't think things through as suggestions were made. Probably too late to change the meaning of existing options now, though. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 23 17:24:05 2024 Received: (at 68666) by debbugs.gnu.org; 23 Jan 2024 22:24:06 +0000 Received: from localhost ([127.0.0.1]:44098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSPBd-0004ws-Je for submit@debbugs.gnu.org; Tue, 23 Jan 2024 17:24:05 -0500 Received: from frenzy.freefriends.org ([198.99.81.75]:34314 helo=freefriends.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSPBc-0004wj-Hi for 68666@debbugs.gnu.org; Tue, 23 Jan 2024 17:24:05 -0500 X-Envelope-From: karl@freefriends.org Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 40NMNoVM000926 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Jan 2024 15:23:50 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 40NMNoYr000925; Tue, 23 Jan 2024 15:23:50 -0700 Date: Tue, 23 Jan 2024 15:23:50 -0700 Message-Id: <202401232223.40NMNoYr000925@freefriends.org> From: Karl Berry To: eggert@cs.ucla.edu Subject: Re: bug#68666: warning if --exclude-dir arg contains /? In-Reply-To: <59cb3b5d-8419-43f6-9ec0-31565b8e8a5e@cs.ucla.edu> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68666 Cc: 68666@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) That's not quite true, as it can match command-line arguments. I see. Perhaps the manual could be a little less terse than expecting readers to understand the difference between "name suffix" and "base name". Ok, it's clear in retrospect, but ... maybe something like (not sure I got it correct): --- Skip any command-line directory with a name suffix (possibly with several file name components) that matches the pattern @var{glob}. When searching recursively, skip any subdirectory whose base name (the last file name component) matches @var{glob}. Ignore any redundant trailing slashes in @var{glob}. In other words if @var{glob} contains a @samp{/} (except for the ignored trailing slashes), the pattern will never match when searching recursively, but may match against explicit command line arguments. --- It should be possible to give useful warnings in some cases, though. If glob contains a / and there are no command line args, it seems a warning is warranted? Probably too late to change the meaning of existing options now, Agreed. --thanks, karl.