]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsmem: add support for LSMEM_COLUMNS environmental variable
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Sat, 30 Aug 2025 17:09:40 +0000 (13:09 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 2 Sep 2025 17:04:29 +0000 (13:04 -0400)
This provides an alternate way to specify output columns similar
to the --output option.

Addresses: #2816
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/lsmem.1.adoc
sys-utils/lsmem.c
tests/ts/lsmem/lsmem

index 337c8b4b7534b58c63bd58e82b94be9c331d3ac9..d588051a816b1c5df070fd596460b97adbbe1b29 100644 (file)
@@ -65,6 +65,11 @@ This option controls summary lines output. The optional argument _when_ can be *
 
 include::man-common/help-version.adoc[]
 
+== ENVIRONMENT
+
+LSMEM_COLUMNS=::
+Specifies a comma-separated list of output columns to print. All columns listed in *--help* can be used.
+
 == AUTHORS
 
 *lsmem* was originally written by Gerald Schaefer for s390-tools in Perl. The C version for util-linux was written by Clemens von Mann, Heiko Carstens and Karel Zak.
index f36e2b1e300106ba4d8162a581c898583c32d2ad..39967bfc9628d5fa773812a6f2a06e8365993a90 100644 (file)
@@ -691,6 +691,8 @@ int main(int argc, char **argv)
                add_column(columns, ncolumns++, COL_BLOCK);
        }
 
+       if (!outarg)
+               outarg = getenv("LSMEM_COLUMNS");
        if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
                                         &ncolumns, column_name_to_id) < 0)
                return EXIT_FAILURE;
index 7dce0f22225147fdcebb02767ceb1f1a2a0c99e3..8654ae3d80ff45043b9c725820c8906e0aa03081 100755 (executable)
@@ -24,7 +24,7 @@ ts_check_test_command "$TS_CMD_LSMEM"
 ts_check_prog "tar"
 ts_check_prog "bzip2"
 
-LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE"
+LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE,ZONES"
 
 
 function do_lsmem {