GNU bug report logs - #15249
"ls -R" may exit with invalid status code

Previous Next

Package: coreutils;

Reported by: FUJIWARA Katsunori <foozy <at> lares.dti.ne.jp>

Date: Mon, 2 Sep 2013 16:20:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15249 in the body.
You can then email your comments to 15249 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#15249; Package coreutils. (Mon, 02 Sep 2013 16:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to FUJIWARA Katsunori <foozy <at> lares.dti.ne.jp>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 02 Sep 2013 16:20:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: FUJIWARA Katsunori <foozy <at> lares.dti.ne.jp>
To: bug-coreutils <at> gnu.org
Subject: "ls -R" may exit with invalid status code
Date: Mon, 02 Sep 2013 21:41:06 +0900
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 <at> lares.dti.ne.jp




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Tue, 03 Sep 2013 19:23:02 GMT) Full text and rfc822 format available.

Notification sent to FUJIWARA Katsunori <foozy <at> lares.dti.ne.jp>:
bug acknowledged by developer. (Tue, 03 Sep 2013 19:23:04 GMT) Full text and rfc822 format available.

Message #10 received at 15249-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: FUJIWARA Katsunori <foozy <at> lares.dti.ne.jp>
Cc: 15249-done <at> debbugs.gnu.org
Subject: Re: bug#15249: "ls -R" may exit with invalid status code
Date: Tue, 03 Sep 2013 20:22:28 +0100
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.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 02 Oct 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.