[pacman-dev] [PATCH] src/pacman: strip any leading / in --overwrite arguments

Joey Pabalinas joeypabalinas at gmail.com
Fri Jun 1 09:50:01 UTC 2018


Allow both `pacman -S foo --overwrite /usr/lib/foo.sh` and
`pacman -S foo --overwrite usr/lib/foo.sh` (with any number
of leading / ignored) to semantically mean the same thing.

Update the documentation to reflect this change.

Signed-off-by: Joey Pabalinas <joeypabalinas at gmail.com>

 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc
index b6f4dd76e1249fd0ec..1bafe3c3c1aedb0051 100644
--- a/doc/pacman.8.asciidoc
+++ b/doc/pacman.8.asciidoc
@@ -263,12 +263,13 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
 	overwritten.  Using '\--overwrite' will not allow overwriting a directory
 	with a file or installing packages with conflicting files and directories.
 	Multiple patterns can be specified by separating them with a comma. May be
 	specified multiple times.  Patterns can be negated, such that files
 	matching them will not be overwritten, by prefixing them with an
-	exclamation mark. Subsequent matches will override previous ones. A leading
-	literal exclamation mark or backslash needs to be escaped.
+	exclamation mark. Subsequent matches will override previous ones. Any
+	leading slashes in the pattern are ignored. A leading literal exclamation
+	mark or backslash needs to be escaped.
 
 
 Query Options (apply to '-Q')[[QO]]
 -----------------------------------
 *-c, \--changelog*::
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index fe54793ea775c03915..f757b4141601587105 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -317,10 +317,12 @@ static void invalid_opt(int used, const char *opt1, const char *opt2)
 static int parsearg_util_addlist(alpm_list_t **list)
 {
 	char *i, *save = NULL;
 
 	for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
+		/* strip any leading slashes */
+		i += strspn(i, "/");
 		*list = alpm_list_add(*list, strdup(i));
 	}
 
 	return 0;
 }
-- 
2.17.0.rc1.35.g90bbd502d54fe92035.dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20180531/b943030f/attachment-0001.asc>


More information about the pacman-dev mailing list