From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jody Bruchon Subject: Re: [PATCH] elkscmd/file_utils/cp.c: add options -b, -n, -v, -u and updated usage Date: Wed, 01 Apr 2015 07:32:07 -0400 Message-ID: <551BD737.8040602@jodybruchon.com> References: <551BD4F2.5030909@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <551BD4F2.5030909@gmail.com> Sender: linux-8086-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: ELKS On 4/1/2015 7:22 AM, Nils Stec wrote: + * Returns -1 if OPT_NOCLOBBER is set and a file is skipped if existent. ... + } else if (ISFLAG(OPT_NOCLOBBER)) { + return -1; ... + retval = copyfile(srcname, destname, 0); + if (!retval) goto error_copy; This causes an error to be returned if someone asks for no clobbering. Doing what is asked for by the user should never be an error condition and should return success unless a true error occurred (i.e. write errors). Here's example output when using the -n switch with GNU coreutils 'cp' and testing for any error conditions: $ ls -l foo bar bar: total 0 -rw-r--r-- 1 user user 0 Apr 1 07:31 1 -rw-r--r-- 1 user user 0 Apr 1 07:31 2 foo: total 12 -rw-r--r-- 1 user user 4 Apr 1 07:31 1 -rw-r--r-- 1 user user 4 Apr 1 07:31 2 -rw-r--r-- 1 user user 4 Apr 1 07:31 3 $ cp -n foo/* bar/ || echo error $ cp -n foo/* bar/ && echo success success $ ls -l foo bar bar: total 4 -rw-r--r-- 1 user user 0 Apr 1 07:31 1 -rw-r--r-- 1 user user 0 Apr 1 07:31 2 -rw-r--r-- 1 user user 4 Apr 1 07:32 3 foo: total 12 -rw-r--r-- 1 user user 4 Apr 1 07:31 1 -rw-r--r-- 1 user user 4 Apr 1 07:31 2 -rw-r--r-- 1 user user 4 Apr 1 07:31 3 $