From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 02 12:19:30 2013 Received: (at submit) by debbugs.gnu.org; 2 Sep 2013 16:19:30 +0000 Received: from localhost ([127.0.0.1]:37683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VGWqe-0004FM-AO for submit@debbugs.gnu.org; Mon, 02 Sep 2013 12:19:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35557) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VGTRr-0006Ea-PN for submit@debbugs.gnu.org; Mon, 02 Sep 2013 08:41:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGTRf-000587-E2 for submit@debbugs.gnu.org; Mon, 02 Sep 2013 08:41:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: *** X-Spam-Status: No, score=3.3 required=5.0 tests=BAYES_50, RECEIVED_FROM_WINDOWS_HOST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGTRf-000582-BO for submit@debbugs.gnu.org; Mon, 02 Sep 2013 08:41:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGTRZ-0007ey-5v for bug-coreutils@gnu.org; Mon, 02 Sep 2013 08:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGTRT-00056C-0R for bug-coreutils@gnu.org; Mon, 02 Sep 2013 08:41:21 -0400 Received: from smtp10.dti.ne.jp ([202.216.231.185]:43215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGTRS-00055n-Io for bug-coreutils@gnu.org; Mon, 02 Sep 2013 08:41:14 -0400 Received: from feefifofum.foozy.private.lares.dti.ne.jp (HKRnm1185.tokyo-ip.dti.ne.jp [59.156.41.185]) by smtp10.dti.ne.jp (3.11s) with ESMTP AUTH id r82Cf7es017604 for ; Mon, 2 Sep 2013 21:41:09 +0900 (JST) Date: Mon, 02 Sep 2013 21:41:06 +0900 Message-ID: From: FUJIWARA Katsunori To: bug-coreutils@gnu.org Subject: "ls -R" may exit with invalid status code User-Agent: Wanderlust/2.15.7 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.3 (i386-msvc-nt6.1.7601) MULE/5.0 (SAKAKI) Meadow/3.02-dev (RINDOU) (2009-06-17 Rev.4261) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 02 Sep 2013 12:19:26 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -2.4 (--) With recent "src/ls.c" implementation of coreutils, "ls -R" may exit with invalid status code LS_FAILURE, even when it should exit with LS_MINOR_PROBLEM, which means some failure for files/directories in sub-directories. Technical detail: "command_line_arg" argument of "gobble_file()" invocation in "print_dir()" is always "false", because it is invoked for files/directories under target directory: they never be command line argument. In the other hand, "command_line_arg" argument of "extract_dirs_from_files()" invocation in "print_dir()" is equal to "command_line_arg" of "print_dir()", even though directories under target one never be command line argument. This causes that every sub-directories in recursive listing are treated as command line argument, and "serious" argument of "file_failure()" invocation for them becomes "true" unexpectedly. Then, "ls -R" will exit with invalid status code LS_FAILURE, when some failure occur for files/directories in sub-directories. The change below should fix this issue. diff --git a/src/ls.c b/src/ls.c index e341c67..08e86ce 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2647,7 +2647,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) contents listed rather than being mentioned here as files. */ if (recursive) - extract_dirs_from_files (name, command_line_arg); + extract_dirs_from_files (name, false); if (format == long_format || print_block_size) { ---------------------------------------------------------------------- [FUJIWARA Katsunori] foozy@lares.dti.ne.jp From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 15:22:38 2013 Received: (at 15249-done) by debbugs.gnu.org; 3 Sep 2013 19:22:38 +0000 Received: from localhost ([127.0.0.1]:39463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VGwBR-0007Ef-Lo for submit@debbugs.gnu.org; Tue, 03 Sep 2013 15:22:38 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:12275) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VGwBP-0007EQ-Do for 15249-done@debbugs.gnu.org; Tue, 03 Sep 2013 15:22:36 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAPY1JlJtT7lX/2dsb2JhbAANTsIugnOBRIMYAQEBBDIBFDIQCw0LCRYPCQMCAQIBRQYNAQcBAa8khH2NI492B4QdA55IjjQ Received: from unknown (HELO [192.168.1.79]) ([109.79.185.87]) by mail2.vodafone.ie with ESMTP; 03 Sep 2013 20:22:29 +0100 Message-ID: <522636F4.7020205@draigBrady.com> Date: Tue, 03 Sep 2013 20:22:28 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: FUJIWARA Katsunori Subject: Re: bug#15249: "ls -R" may exit with invalid status code References: In-Reply-To: X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15249-done Cc: 15249-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: 0.0 (/) On 09/02/2013 01:41 PM, FUJIWARA Katsunori wrote: > With recent "src/ls.c" implementation of coreutils, "ls -R" may exit > with invalid status code LS_FAILURE, even when it should exit with > LS_MINOR_PROBLEM, which means some failure for files/directories in > sub-directories. > > Technical detail: > > "command_line_arg" argument of "gobble_file()" invocation in > "print_dir()" is always "false", because it is invoked for > files/directories under target directory: they never be command line > argument. > > In the other hand, "command_line_arg" argument of > "extract_dirs_from_files()" invocation in "print_dir()" is equal to > "command_line_arg" of "print_dir()", even though directories under > target one never be command line argument. > > This causes that every sub-directories in recursive listing are > treated as command line argument, and "serious" argument of > "file_failure()" invocation for them becomes "true" unexpectedly. > > Then, "ls -R" will exit with invalid status code LS_FAILURE, when > some failure occur for files/directories in sub-directories. > > The change below should fix this issue. > > diff --git a/src/ls.c b/src/ls.c > index e341c67..08e86ce 100644 > --- a/src/ls.c > +++ b/src/ls.c > @@ -2647,7 +2647,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) > contents listed rather than being mentioned here as files. */ > > if (recursive) > - extract_dirs_from_files (name, command_line_arg); > + extract_dirs_from_files (name, false); > > if (format == long_format || print_block_size) > { This looks correct on initial inspection. I'll look a bit more closely and apply soon. thanks, Pádraig. From unknown Wed Jun 25 00:24:56 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 02 Oct 2013 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator