Commit a8d9fb8d authored by Jonathan Sköld's avatar Jonathan Sköld Committed by Allan McRae
Browse files

Print the target arch when using the %a format specifier



Adds the %a format specifier to allow printing of a target's arch
when using --print-format.
Signed-off-by: default avatarJonathan Sköld <arch@skold.dev>
Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
parent 446972b4
Pipeline #14264 passed with stage
in 1 minute and 56 seconds
......@@ -235,8 +235,9 @@ Transaction Options (apply to '-S', '-R' and '-U')
*\--print-format* <format>::
Specify a printf-like format to control the output of the '\--print'
operation. The possible attributes are: "%n" for pkgname, "%v" for pkgver,
"%l" for location, "%r" for repository, and "%s" for size. Implies '\--print'.
operation. The possible attributes are: "%a" for arch, "%n" for pkgname,
"%v" for pkgver, "%l" for location, "%r" for repository, and "%s" for size.
Implies '\--print'.
Upgrade Options (apply to '-S' and '-U')[[UO]]
......
......@@ -1146,6 +1146,16 @@ void print_packages(const alpm_list_t *packages)
alpm_pkg_t *pkg = i->data;
char *string = strdup(config->print_format);
char *temp = string;
/* %a : arch */
if(strstr(temp, "%a")) {
const char *arch = alpm_pkg_get_arch(pkg);
if(arch == NULL) {
arch = "";
}
string = strreplace(temp, "%a", arch);
free(temp);
temp = string;
}
/* %n : pkgname */
if(strstr(temp, "%n")) {
string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment