diff options
-rw-r--r-- | src/copy.c | 5 | ||||
-rw-r--r-- | src/copy.h | 3 | ||||
-rw-r--r-- | src/cp.c | 1 | ||||
-rw-r--r-- | src/install.c | 1 | ||||
-rw-r--r-- | src/mv.c | 1 | ||||
-rwxr-xr-x | tests/cp/link-deref.sh | 2 | ||||
-rwxr-xr-x | tests/install/basic-1.sh | 5 |
7 files changed, 16 insertions, 2 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; @@ -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; @@ -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; diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh index 51b228cbb..f5b7160a6 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -92,7 +92,7 @@ for src in dirlink filelink danglink; do exp_result=1 exp_inode= exp_ftype= - exp_error="cp: omitting directory 'dirlink'" + exp_error="cp: -r not specified; omitting directory 'dirlink'" elif [ "$src" = 'dirlink' ]; then # cp --link -R 'dirlink' should create a new directory. exp_result=0 diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh index 23a2d581f..1a7147c1f 100755 --- a/tests/install/basic-1.sh +++ b/tests/install/basic-1.sh @@ -143,4 +143,9 @@ compare - out <<\EOF || fail=1 'file' -> 'sub4/dir_exists/file' EOF +# Ensure omitted directories are diagnosed +returns_ 1 ginstall . . 2>err || fail=1 +printf '%s\n' "ginstall: omitting directory '.'" >exp || framework_failure_ +compare exp err || fail=1 + Exit $fail |