From: Karel Zak Date: Mon, 14 Feb 2022 12:59:29 +0000 (+0100) Subject: findmnt: add -y,--shell X-Git-Tag: v2.38-rc2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=152c17aa469287b31382e9eefa00169f3838d3ed;p=thirdparty%2Futil-linux.git findmnt: add -y,--shell Signed-off-by: Karel Zak --- diff --git a/misc-utils/findmnt.8.adoc b/misc-utils/findmnt.8.adoc index a92fbe6b4b..f7c046d03f 100644 --- a/misc-utils/findmnt.8.adoc +++ b/misc-utils/findmnt.8.adoc @@ -104,7 +104,7 @@ The default list of columns may be extended if _list_ is specified in the format Output almost all available columns. The columns that require *--poll* are not included. *-P*, *--pairs*:: -Produce output in the form of key="value" pairs. All potentially unsafe value characters are hex-escaped (\x). The key (variable name) will be modified to contain only characters allowed for a shell variable identifiers, for example, FS_OPTIONS and USE_PCT instead of FS-OPTIONS and USE%. +Produce output in the form of key="value" pairs. All potentially unsafe value characters are hex-escaped (\x). See also option *--shell*. *-p*, *--poll*[_=list_]:: Monitor changes in the _/proc/self/mountinfo_ file. Supported actions are: mount, umount, remount and move. More than one action may be specified in a comma-separated list. All actions are monitored by default. @@ -174,6 +174,9 @@ Force *findmnt* to print more information (*--verify* only for now). *--vfs-all*:: When used with *VFS-OPTIONS* column, print all VFS (fs-independent) flags. This option is designed for auditing purposes to list also default VFS kernel mount options which are normally not listed. +*-y*, *--shell*:: +The column name will be modified to contain only characters allowed for shell variable identifiers. 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*. + include::man-common/help-version.adoc[] == EXIT STATUS diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index e3095d974e..733bbc13d2 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -1371,6 +1371,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -U, --uniq ignore filesystems with duplicate target\n"), out); fputs(_(" -u, --notruncate don't truncate text in columns\n"), out); fputs(_(" -v, --nofsroot don't print [/dir] for bind or btrfs mounts\n"), out); + fputs(_(" -y, --shell use column names to be usable as shell variable identifiers\n"), out); fputc('\n', out); fputs(_(" -x, --verify verify mount table content (default is fstab)\n"), out); @@ -1450,6 +1451,7 @@ int main(int argc, char *argv[]) { "uniq", no_argument, NULL, 'U' }, { "verify", no_argument, NULL, 'x' }, { "version", no_argument, NULL, 'V' }, + { "shell", no_argument, NULL, 'y' }, { "verbose", no_argument, NULL, FINDMNT_OPT_VERBOSE }, { "tree", no_argument, NULL, FINDMNT_OPT_TREE }, { "real", no_argument, NULL, FINDMNT_OPT_REAL }, @@ -1482,7 +1484,7 @@ int main(int argc, char *argv[]) flags |= FL_TREE; while ((c = getopt_long(argc, argv, - "AabCcDd:ehiJfF:o:O:p::PklmM:nN:rst:uvRS:T:Uw:Vx", + "AabCcDd:ehiJfF:o:O:p::PklmM:nN:rst:uvRS:T:Uw:Vxy", longopts, NULL)) != -1) { err_exclusive_options(c, longopts, excl, excl_st); @@ -1619,6 +1621,9 @@ int main(int argc, char *argv[]) case 'x': verify = 1; break; + case 'y': + flags |= FL_SHELLVAR; + break; case FINDMNT_OPT_VERBOSE: flags |= FL_VERBOSE; break; @@ -1760,6 +1765,7 @@ int main(int argc, char *argv[]) } scols_table_enable_raw(table, !!(flags & FL_RAW)); scols_table_enable_export(table, !!(flags & FL_EXPORT)); + scols_table_enable_shellvar(table, !!(flags & FL_SHELLVAR)); scols_table_enable_json(table, !!(flags & FL_JSON)); scols_table_enable_ascii(table, !!(flags & FL_ASCII)); scols_table_enable_noheadings(table, !!(flags & FL_NOHEADINGS));