]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findmnt: add -y,--shell
authorKarel Zak <kzak@redhat.com>
Mon, 14 Feb 2022 12:59:29 +0000 (13:59 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 14 Feb 2022 12:59:29 +0000 (13:59 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findmnt.8.adoc
misc-utils/findmnt.c

index a92fbe6b4b3b0e901762473bc213d52a7a8631b6..f7c046d03f5ff242fabf2874a26c1e902611c012 100644 (file)
@@ -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<code>). 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<code>). 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
index e3095d974e4731c6747c94c1fe34b0b7860c823f..733bbc13d23ace02d3457256186bc5ec51370140 100644 (file)
@@ -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));