]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add support for LSCPU_{CACHES_}COLUMNS environment variables
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 2 Sep 2025 18:30:01 +0000 (14:30 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 2 Sep 2025 19:33:24 +0000 (15:33 -0400)
This provides alternate ways of specifying output columns similar
to the '--parse', '--extended' and '--caches' options.

Addresses: #2816
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/lscpu.c

index 99799594e7e8810aaad6b033dbde4a2462597528..fe0eac9e7e9bffbbb6d53376593f50970ffbcaf4 100644 (file)
@@ -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);