summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-11-19 11:26:43 +0000
committerPádraig Brady <P@draigBrady.com>2016-11-19 17:05:33 +0000
commitf1799198483171c8565a4ff8fc1205d0a52fce37 (patch)
treefcd58921c28ced224cf33f7c4cb45871a385ae91 /src
parent0c5cc8384a84ad39f7788ed1c5092bc14a0431ce (diff)
downloadcoreutils-f1799198483171c8565a4ff8fc1205d0a52fce37.tar.xz
cp: improve status message when omitting directories
* src/copy.h (cp_options): Add a new flag for install(1). * src/copy.c (copy_internal): For cp, also output remediation advice which also indicates why directories aren't copied by default. The message is unchanged for install(1). * src/cp.c (cp_option_init): Init install_mode to false. * src/mv.c (cp_option_init): Likewise. * src/install.c (cp_option_init): Init install_mode to true. * tests/install/basic-1.sh: Add a test case. * tests/cp/link-deref.sh: Adjust test case. Fixes http://bugs.gnu.org/24958
Diffstat (limited to 'src')
-rw-r--r--src/copy.c5
-rw-r--r--src/copy.h3
-rw-r--r--src/cp.c1
-rw-r--r--src/install.c1
-rw-r--r--src/mv.c1
5 files changed, 10 insertions, 1 deletions
diff --git a/src/copy.c b/src/copy.c
index 422d50efe..b3acff347 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1873,7 +1873,10 @@ copy_internal (char const *src_name, char const *dst_name,
if (S_ISDIR (src_mode) && !x->recursive)
{
- error (0, 0, _("omitting directory %s"), quoteaf (src_name));
+ error (0, 0, ! x->install_mode /* cp */
+ ? _("-r not specified; omitting directory %s")
+ : _("omitting directory %s"),
+ quoteaf (src_name));
return false;
}
diff --git a/src/copy.h b/src/copy.h
index fa0c2aeae..a516002c2 100644
--- a/src/copy.h
+++ b/src/copy.h
@@ -137,6 +137,9 @@ struct cp_options
If that fails, then resort to copying. */
bool move_mode;
+ /* If true, install(1) is the caller. */
+ bool install_mode;
+
/* Whether this process has appropriate privileges to chown a file
whose owner is not the effective user ID. */
bool chown_privileges;
diff --git a/src/cp.c b/src/cp.c
index 926e05be3..1b528c6a2 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -771,6 +771,7 @@ cp_option_init (struct cp_options *x)
x->hard_link = false;
x->interactive = I_UNSPECIFIED;
x->move_mode = false;
+ x->install_mode = false;
x->one_file_system = false;
x->reflink_mode = REFLINK_NEVER;
diff --git a/src/install.c b/src/install.c
index 4fa4bb3d3..414d645cc 100644
--- a/src/install.c
+++ b/src/install.c
@@ -271,6 +271,7 @@ cp_option_init (struct cp_options *x)
x->hard_link = false;
x->interactive = I_UNSPECIFIED;
x->move_mode = false;
+ x->install_mode = true;
x->one_file_system = false;
x->preserve_ownership = false;
x->preserve_links = false;
diff --git a/src/mv.c b/src/mv.c
index 6a3d0d277..04d2be3ec 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -114,6 +114,7 @@ cp_option_init (struct cp_options *x)
x->hard_link = false;
x->interactive = I_UNSPECIFIED;
x->move_mode = true;
+ x->install_mode = false;
x->one_file_system = false;
x->preserve_ownership = true;
x->preserve_links = true;