GNU bug report logs -
#15249
"ls -R" may exit with invalid status code
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Tue, 03 Sep 2013 20:22:28 +0100
with message-id <522636F4.7020205 <at> draigBrady.com>
and subject line Re: bug#15249: "ls -R" may exit with invalid status code
has caused the debbugs.gnu.org bug report #15249,
regarding "ls -R" may exit with invalid status code
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
15249: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15249
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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
[Message part 3 (message/rfc822, inline)]
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.
This bug report was last modified 11 years and 268 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.