From 8e4d8ff938089b8369c6fe071fed901d143b9181 Mon Sep 17 00:00:00 2001 From: Christian Goeschel Ndjomouo Date: Tue, 2 Sep 2025 14:30:01 -0400 Subject: [PATCH] lscpu: add support for LSCPU_{CACHES_}COLUMNS environment variables This provides alternate ways of specifying output columns similar to the '--parse', '--extended' and '--caches' options. Addresses: #2816 Signed-off-by: Christian Goeschel Ndjomouo --- sys-utils/lscpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 99799594e..fe0eac9e7 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -1395,6 +1395,11 @@ int main(int argc, char *argv[]) if (hierarchic == -1) hierarchic = isatty(STDOUT_FILENO); /* default */ + if (!outarg && (cxt->mode == LSCPU_OUTPUT_CACHES)) + outarg = getenv("LSCPU_CACHES_COLUMNS"); + if (!outarg && ((cxt->mode == LSCPU_OUTPUT_PARSABLE) || (cxt->mode == LSCPU_OUTPUT_READABLE))) + outarg = getenv("LSCPU_COLUMNS"); + switch(cxt->mode) { case LSCPU_OUTPUT_SUMMARY: print_summary(cxt); -- 2.47.3