From: Jody Bruchon <jody@jodybruchon.com>
To: ELKS <linux-8086@vger.kernel.org>
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 [thread overview]
Message-ID: <551BD737.8040602@jodybruchon.com> (raw)
In-Reply-To: <551BD4F2.5030909@gmail.com>
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
$
next prev parent reply other threads:[~2015-04-01 11:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 11:22 [PATCH] elkscmd/file_utils/cp.c: add options -b, -n, -v, -u and updated usage Nils Stec
2015-04-01 11:32 ` Jody Bruchon [this message]
2015-04-01 11:41 ` Nils Stec
2015-04-01 12:35 ` Jody Bruchon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551BD737.8040602@jodybruchon.com \
--to=jody@jodybruchon.com \
--cc=linux-8086@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox