[pacman-dev] [PATCH] Strip leading "/" from arguments to --overwrite

Allan McRae allan at archlinux.org
Tue May 29 04:28:28 UTC 2018


The arguments for the --overwrite option requried the user to strip the
leading "/" from the path. It is more intuative to provide the whole
path and have pacman strip the leading "/" before passing to the
backend.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 src/pacman/pacman.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index fe54793e..d90a9f6c 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -723,7 +723,16 @@ static int parsearg_upgrade(int opt)
 			config->flags |= ALPM_TRANS_FLAG_FORCE;
 			break;
 		case OP_OVERWRITE_FILES:
-			parsearg_util_addlist(&(config->overwrite_files));
+			{
+				char *i, *save = NULL;
+				for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
+					/* strip leading "/" before adding to option list */
+					while(i[0] == '/') {
+						i = i + 1;
+					}
+					config->overwrite_files = alpm_list_add(config->overwrite_files, strdup(i));
+				}
+			}
 			break;
 		case OP_ASDEPS:
 			config->flags |= ALPM_TRANS_FLAG_ALLDEPS;
-- 
2.17.0


More information about the pacman-dev mailing list