Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2002 09:00:11 -0700 (PDT)
From:      Slaven Rezic <slaven.rezic@berlin.de>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/42789: cp -p may report wrong exit status
Message-ID:  <200209161600.g8GG0BjV064698@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/42789; it has been noted by GNATS.

From: Slaven Rezic <slaven.rezic@berlin.de>
To: Ralf Becker <ralf@akk.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/42789: cp -p may report wrong exit status
Date: 16 Sep 2002 15:55:41 +0200

 Ralf Becker <ralf@akk.org> writes:
 
 > In my opinion slaven's fixed the problem at the wrong place.
 > The error is caused by the fact that there is no check of the return
 > value after calling one one of the copy_* functions.
 > Isn't it enough to do this at the end of the loop ?
 
 The current behavior is that cp tries to copy all traversed files,
 regardless of an error in an individual copy. If there was at least
 one error, then rval is set to 1 and returned at the end of cp (except
 for the bug below).
 
 So you want to stop cp at the first error? What's the opinion of POSIX
 on this?
 
 Regards,
 	Slaven
 
 
 > *** cp.c.orig	Mon Sep 16 13:19:16 2002
 > --- cp.c	Mon Sep 16 13:26:26 2002
 > ***************
 > *** 445,450 ****
 > --- 445,454 ----
 >   		}
 >   		if (vflag && !badcp)
 >   			(void)printf("%s -> %s\n", curr->fts_path, to.p_path);
 > + 		if ( rval != 0 || badcp != 0) {
 > + 			/* error occured */
 > + 			break;
 > + 		}
 >   	}
 >   	if (errno)
 >   		err(1, "fts_read");
 > 
 
 -- 
 Slaven Rezic - slaven.rezic@berlin.de
 
     tksm - Perl/Tk program for searching and replacing in multiple files
     http://ptktools.sourceforge.net/#tksm

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209161600.g8GG0BjV064698>