From unknown Wed Jun 25 00:26:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15249: "ls -R" may exit with invalid status code Resent-From: FUJIWARA Katsunori Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 02 Sep 2013 16:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15249 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 15249@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.137813877016336 (code B ref -1); Mon, 02 Sep 2013 16:20:02 +0000 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 User-Agent: Wanderlust/2.15.7 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) 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-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 unknown Wed Jun 25 00:26:07 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: FUJIWARA Katsunori Subject: bug#15249: closed (Re: bug#15249: "ls -R" may exit with invalid status code) Message-ID: References: <522636F4.7020205@draigBrady.com> X-Gnu-PR-Message: they-closed 15249 X-Gnu-PR-Package: coreutils Reply-To: 15249@debbugs.gnu.org Date: Tue, 03 Sep 2013 19:23:04 +0000 Content-Type: multipart/mixed; boundary="----------=_1378236184-27862-1" This is a multi-part message in MIME format... ------------=_1378236184-27862-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #15249: "ls -R" may exit with invalid status code which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 15249@debbugs.gnu.org. --=20 15249: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15249 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1378236184-27862-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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. ------------=_1378236184-27862-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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 ------------=_1378236184-27862-1--