From: cgoesche Date: Sat, 23 Aug 2025 00:26:07 +0000 (-0400) Subject: lsblk: add support for LSBLK_COLUMNS environmental variable as an alternative to... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80fcb7a5f65b68919cb4390a606ef4a3dbbca5b4;p=thirdparty%2Futil-linux.git lsblk: add support for LSBLK_COLUMNS environmental variable as an alternative to --output Addresses: #2816 Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/misc-utils/lsblk.8.adoc b/misc-utils/lsblk.8.adoc index 04efa276c..4fc6cc6b5 100644 --- a/misc-utils/lsblk.8.adoc +++ b/misc-utils/lsblk.8.adoc @@ -234,6 +234,9 @@ enables *libsmartcols* debug output. *LIBSMARTCOLS_DEBUG_PADDING*=on:: use visible padding characters. +*LSBLK_COLUMNS*=:: +specifies a comma-separated list of output columns to print. All columns listed by *--list-columns* can be used. + == NOTES For partitions, some information (e.g., queue attributes) is inherited from the parent device. diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 06a206cb9..c054c23b4 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -2714,6 +2714,7 @@ int main(int argc, char *argv[]) add_column(COL_TARGETS); } + outarg = outarg == NULL ? getenv("LSBLK_COLUMNS") : outarg; if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns), &ncolumns, column_name_to_id) < 0) return EXIT_FAILURE;