Not sure if this is the right mailing list for this, the website was a
bit unclear on this.
This patch is not finished, it’s missing tests (if that is necessary)
and documentation, but I’d like to get feedback on whether this is a
welcome change.
The motivation behind this change is that I’d like to make an alias for
cp and mv that automatically passes -T to avoid accidentally using the
wrong behaviour, but would still like to be able to invoke that
behaviour explicitly. This change makes a -T flag combined with a -t
option behave as if the -T flag wasn’t passed.
—Anselm Schüler
From b91969acb7f13869edf4d884aad79e213b412b84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anselm=20Sch=C3=BCler?= <[email protected]>
Date: Fri, 20 Feb 2026 16:34:14 +0100
Subject: [PATCH] mv, cp: allow -t together with -T
-T check is simply ignored if -t is present
* src/cp.c (do_copy):
* src/mv.c (main):
Allow -t to set a target directory even if -T is given, overriding it.
---
src/cp.c | 6 +-----
src/mv.c | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/cp.c b/src/cp.c
index e17484b5d..d94f745d3 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -685,12 +685,8 @@ do_copy (int n_files, char **file, char const *target_directory,
int target_dirfd = AT_FDCWD;
bool new_dst = false;
bool ok = true;
- if (no_target_directory)
+ if (no_target_directory && !target_directory)
{
- if (target_directory)
- error (EXIT_FAILURE, 0,
- _("cannot combine --target-directory (-t) "
- "and --no-target-directory (-T)"));
if (2 < n_files)
{
error (0, 0, _("extra operand %s"), quoteaf (file[2]));
diff --git a/src/mv.c b/src/mv.c
index cd6aab473..5201f4901 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -452,12 +452,8 @@ main (int argc, char **argv)
struct stat sb;
sb.st_mode = 0;
int target_dirfd = AT_FDCWD;
- if (no_target_directory)
+ if (no_target_directory && !target_directory)
{
- if (target_directory)
- error (EXIT_FAILURE, 0,
- _("cannot combine --target-directory (-t) "
- "and --no-target-directory (-T)"));
if (2 < n_files)
{
error (0, 0, _("extra operand %s"), quoteaf (file[2]));
--
2.52.0