zdev: implement --shell command line switch

Fix issue in the lszdev command where column names if using the --pairs
command line switch can contain characters that are not allowed to be
used as variable names in a shell environment.

Replace bad characters in column names by an underscore if the --shell
command line switch is specified along with the --pairs switch.

The additional --shell switch mimics what is already available in the
lsblk command and thus it shall be used along with the --pairs switch.

Signed-off-by: Daniel S. Haischt <modean@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Daniel S. Haischt
2022-12-05 18:42:15 +01:00
committed by Steffen Eiden
parent 0c5b9f5d11
commit 889293e557
9 changed files with 81 additions and 13 deletions
+11
View File
@@ -423,6 +423,17 @@ with the name of the corresponding column. Values are enclosed in double
quotation marks. Any quotation marks or slashes in the value string are
escaped by placing a slash in front of it.
.PP
.OD shell "" ""
Produces KEY="VALUE" format usable as shell variables.
You can use this option together with the --pairs option to generate
output that is suitable to be sourced in a shell environment. This
option generates similar output as it would be provided by the --pairs
option but it would take care of replacing any character of a column
name that would not be appropriate to be used as part of a shell
variable name by an underscore.
.PP
.
.OD persistent "p" ""
List information from the persistent configuration only.