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

Andrew Gregory andrew.gregory.8 at gmail.com
Fri Jun 1 21:13:37 UTC 2018


On 05/29/18 at 02:28pm, Allan McRae wrote:
> 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

If we're going to allow absolute paths, should we not be removing the
full root, not just '/'?


More information about the pacman-dev mailing list