Re: [PATCH] elkscmd/file_utils/cp.c: add options -b, -n, -v, -u and updated usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
$

--
To unsubscribe from this list: send the line "unsubscribe linux-8086" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux