Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] cp: allow multiple --preserve flags
- X-seq: zsh-workers 54208
- From: Ronan Pigott <ronan@xxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Ronan Pigott <ronan@xxxxxx>
- Subject: [PATCH] cp: allow multiple --preserve flags
- Date: Tue, 24 Feb 2026 19:14:42 -0700
- Archived-at: <https://zsh.org/workers/54208>
- List-id: <zsh-workers.zsh.org>
The '--preserve' flag is valid multiple times on the command line.
My use case is that I have defined an alias cp='cp --preserve=xattr',
but sometimes I'd like to additionally --preserve=timestamps. While it
is valid to invoke cp with two --preserve flags, the completions as
defined do not allow it, so --preserve is always completed to
--no-preserve when I attempt completion.
---
Completion/Unix/Command/_cp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Completion/Unix/Command/_cp b/Completion/Unix/Command/_cp
index 0263115b3717..937775d4c5d5 100644
--- a/Completion/Unix/Command/_cp
+++ b/Completion/Unix/Command/_cp
@@ -16,8 +16,8 @@ if _pick_variant gnu='(GNU|uutils)' unix --version; then
'(-n --no-clobber -i --interactive)'{-n,--no-clobber}"[don't overwrite an existing file]" \
'(-P --no-dereference)'{-P,--no-dereference}'[never follow symbolic links]' \
'-p[same as --preserve=mode,ownership,timestamps]' \
- '--preserve=-[preserve specified attributes]:: :_values -s , attribute mode timestamps ownership links context xattr all' \
- "--no-preserve=[don't preserve specified attributes]: :_values -s , attribute mode timestamps ownership links context xattr all" \
+ '*--preserve=-[preserve specified attributes]:: :_values -s , attribute mode timestamps ownership links context xattr all' \
+ "*--no-preserve=[don't preserve specified attributes]: :_values -s , attribute mode timestamps ownership links context xattr all" \
'--parents[append source path to target directory]' \
'(-R -r --recursive)'{-R,-r,--recursive}'[copy directories recursively]' \
'--reflink=-[control clone/CoW copies]::when to perform a lightweight copy:(always auto)' \
--
2.53.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author