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

index fdf29ec27a3af1a79f3e2c182299433876ebbc04..3ee790e2177652658ae680b515b0c9b4f4e323a2 100644 (file)
@@ -45,7 +45,7 @@ Write information about active semaphore sets.
 Show creator and owner.
 
 *-e*, *--export*::
-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, USE_PCT instead of USE%.
+Produce output in the form of key="value" pairs. All potentially unsafe value characters are hex-escaped (\x<code>). See also option *--shell*.
 
 *-J*, *--json*::
 Use the JSON output format.
@@ -80,6 +80,9 @@ Display dates in short, full or iso format. The default is short, this time form
 *-P*, *--numeric-perms*::
 Print numeric permissions in PERMS column.
 
+*-y*, *--shell*::
+The column name will be modified to contain only characters allowed for shell variable identifiers. This is usable, for example, with *--export*. Note that this feature has been automatically enabled for *--export* in version 2.37, but due to compatibility issues, now it's necessary to request this behavior by *--shell*.
+
 == EXIT STATUS
 
 0::
index d209f4507d90b1e4212242aaaf7c4cf38cd91a90..0f3cd94bbc6578e7e0fc722246c0e01b9719387e 100644 (file)
@@ -129,6 +129,7 @@ struct lsipc_control {
        int outmode;
        unsigned int noheadings : 1,            /* don't print header line */
                     notrunc : 1,               /* don't truncate columns */
+                    shellvar : 1,              /* use shell compatible colum names */
                     bytes : 1,                 /* SIZE in bytes */
                     numperms : 1,              /* numeric permissions */
                     time_mode : 2;
@@ -315,6 +316,8 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -P, --numeric-perms      print numeric permissions (PERMS column)\n"), out);
        fputs(_(" -r, --raw                display in raw mode\n"), out);
        fputs(_(" -t, --time               show attach, detach and change times\n"), out);
+       fputs(_(" -y, --shell              use column names to be usable as shell variable identifiers\n"), out);
+
 
        fputs(USAGE_SEPARATOR, out);
        printf(USAGE_HELP_OPTIONS(26));
@@ -352,6 +355,8 @@ static struct libscols_table *new_table(struct lsipc_control *ctl)
 
        if (ctl->noheadings)
                scols_table_enable_noheadings(table, 1);
+       if (ctl->shellvar)
+               scols_table_enable_shellvar(table, 1);
 
        switch(ctl->outmode) {
        case OUT_NEWLINE:
@@ -1132,6 +1137,7 @@ int main(int argc, char *argv[])
                { "time",           no_argument,        NULL, 't' },
                { "time-format",    required_argument,  NULL, OPT_TIME_FMT },
                { "version",        no_argument,        NULL, 'V' },
+               { "shell",          no_argument,        NULL, 'y' },
                {NULL, 0, NULL, 0}
        };
 
@@ -1153,7 +1159,7 @@ int main(int argc, char *argv[])
 
        scols_init_debug(0);
 
-       while ((opt = getopt_long(argc, argv, "bceghi:Jlmno:PqrstV", longopts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "bceghi:Jlmno:PqrstVy", longopts, NULL)) != -1) {
 
                err_exclusive_options(opt, longopts, excl, excl_st);
 
@@ -1242,6 +1248,9 @@ int main(int argc, char *argv[])
                case 'c':
                        show_creat = 1;
                        break;
+               case 'y':
+                       ctl->shellvar = 1;
+                       break;
 
                case 'h':
                        usage();