Output all available columns.
*-P*, *--pairs*::
-Produce output in the form of key="value" pairs. The output lines are still ordered by dependencies. All potentially unsafe value characters are hex-escaped (\x<code>). The key (variable name) will be modified to contain only characters allowed for a shell variable identifiers, for example, MIN_IO and FSUSE_PCT instead of MIN-IO and FSUSE%.
+Produce output in the form of key="value" pairs. The output lines are still ordered by dependencies. All potentially unsafe value characters are hex-escaped (\x<code>). See also option *--shell*.
*-p*, *--paths*::
Print full device paths.
*-x*, *--sort* _column_::
Sort output lines by _column_. This option enables *--list* output format by default. It is possible to use the option *--tree* to force tree-like output and than the tree branches are sorted by the _column_.
+*-y*, *--shell*::
+The column name will be modified to contain only characters allowed for shell variable identifiers, for example, MIN_IO and FSUSE_PCT instead of MIN-IO and FSUSE%. This is usable, for example, with *--pairs*. Note that this feature has been automatically enabled for *--pairs* in version 2.37, but due to compatibility issues, now it’s necessary to request this behavior by *--shell*.
+
*-z*, *--zoned*::
Print the zone related information for each device.
LSBLK_EXPORT = (1 << 3),
LSBLK_TREE = (1 << 4),
LSBLK_JSON = (1 << 5),
+ LSBLK_SHELLVAR = (1 << 6)
};
/* Types used for qsort() and JSON */
fputs(_(" -t, --topology output info about topology\n"), out);
fputs(_(" -w, --width <num> specifies output width as number of characters\n"), out);
fputs(_(" -x, --sort <column> sort output by <column>\n"), out);
+ fputs(_(" -y, --shell modify column names to be usable as shell variable identifiers\n"), out);
fputs(_(" -z, --zoned print zone related information\n"), out);
fputs(_(" --sysroot <dir> use specified directory as system root\n"), out);
fputs(USAGE_SEPARATOR, out);
{ "scsi", no_argument, NULL, 'S' },
{ "sort", required_argument, NULL, 'x' },
{ "sysroot", required_argument, NULL, OPT_SYSROOT },
+ { "shell", no_argument, NULL, 'y' },
{ "tree", optional_argument, NULL, 'T' },
{ "version", no_argument, NULL, 'V' },
{ "width", required_argument, NULL, 'w' },
lsblk_init_debug();
while((c = getopt_long(argc, argv,
- "AabdDzE:e:fhJlnMmo:OpPiI:rstVST::w:x:",
+ "AabdDzE:e:fhJlnMmo:OpPiI:rstVST::w:x:y",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
lsblk->flags |= LSBLK_EXPORT;
lsblk->flags &= ~LSBLK_TREE; /* disable the default */
break;
+ case 'y':
+ lsblk->flags |= LSBLK_SHELLVAR;
+ break;
case 'i':
lsblk->flags |= LSBLK_ASCII;
break;
errx(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(lsblk->table, !!(lsblk->flags & LSBLK_RAW));
scols_table_enable_export(lsblk->table, !!(lsblk->flags & LSBLK_EXPORT));
+ scols_table_enable_shellvar(lsblk->table, !!(lsblk->flags & LSBLK_SHELLVAR));
scols_table_enable_ascii(lsblk->table, !!(lsblk->flags & LSBLK_ASCII));
scols_table_enable_json(lsblk->table, !!(lsblk->flags & LSBLK_JSON));
scols_table_enable_noheadings(lsblk->table, !!(lsblk->flags & LSBLK_NOHEADINGS));