[PATCH] diff: return 1 when skipping directories with -r, but without -N

Denys Vlasenko vda.linux at googlemail.com
Wed Jan 26 00:09:36 UTC 2011


On Tuesday 25 January 2011 17:24, Roman Borisov wrote:
> On 01/25/2011 07:03 PM, ext Alexander Shishkin wrote:
> > Diff in diffutils will return 1 in case -r option is specified without
> > -N something exists only in one of the directories.
> >
> > Signed-off-by: Alexander Shishkin<virtuoso at slind.org>
> > ---
> >   editors/diff.c |    9 ++++++---
> >   1 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/editors/diff.c b/editors/diff.c
> > index cc7ba47..ca4a4ea 100644
> > --- a/editors/diff.c
> > +++ b/editors/diff.c
> > @@ -794,7 +794,9 @@ static int FAST_FUNC skip_dir(const char *filename,
> >   			free(othername);
> >   			if (r != 0 || !S_ISDIR(osb.st_mode)) {
> >   				/* other dir doesn't have similarly named
> > -				 * directory, don't recurse */
> > +				 * directory, don't recurse; return 1 upon
> > +				 * exit, just like diffutils' diff */
> > +				exit_status |= 1;
> >   				return SKIP;
> >   			}
> >   		}
> > @@ -846,9 +848,10 @@ static void diffdir(char *p[2], const char *s_start)
> >   			break;
> >   		pos = !dp[0] ? 1 : (!dp[1] ? -1 : strcmp(dp[0], dp[1]));
> >   		k = pos>  0;
> > -		if (pos&&  !(option_mask32&  FLAG(N)))
> > +		if (pos&&  !(option_mask32&  FLAG(N))) {
> >   			printf("Only in %s: %s\n", p[k], dp[k]);
> > -		else {
> > +			exit_status |= 1;
> > +		} else {
> >   			char *fullpath[2], *path[2]; /* if -N */
> >
> >   			for (i = 0; i<  2; i++) {
> 
> thanks,
> tried the patch;
> the issue was gone: bb->diff returns the same result as diff-utils

Applied, thanks!

-- 
vda


More information about the busybox mailing list