* 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
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;
}
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;
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;
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;
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;
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
'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