From: Masatake YAMATO <yamato@redhat.com>
To: util-linux@vger.kernel.org
Cc: yamato@redhat.com
Subject: [PATCH v2 5/7] lsns: add --nowrap(-W) option
Date: Fri, 24 Nov 2017 19:31:08 +0900 [thread overview]
Message-ID: <20171124103110.17077-7-yamato@redhat.com> (raw)
In-Reply-To: <20171124103110.17077-1-yamato@redhat.com>
This option forces lsns command not use
multi-line presentation when printing a cell.
Currently, it affects only NSFS column.
Implementing this option is suggested by Karl Zak.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
sys-utils/lsns.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index c4d806e24..8af363317 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -173,7 +173,8 @@ struct lsns {
tree : 1,
list : 1,
notrunc : 1,
- no_headings: 1;
+ no_headings: 1,
+ no_wrap : 1;
struct libmnt_table *tab;
};
@@ -746,7 +747,7 @@ static void add_scols_line(struct lsns *ls, struct libscols_table *table,
break;
case COL_NSFS:
nsfs_xasputs(&str, ns, ls->tab,
- ls->raw ? ',' : '\n');
+ (ls->raw || ls->no_wrap) ? ',' : '\n');
break;
default:
break;
@@ -786,6 +787,8 @@ static struct libscols_table *init_scols_table(struct lsns *ls)
flags &= ~SCOLS_FL_TRUNC;
if (ls->tree && get_column_id(i) == COL_COMMAND)
flags |= SCOLS_FL_TREE;
+ if (ls->no_wrap)
+ flags &= ~SCOLS_FL_WRAP;
cl = scols_table_new_column(tab, col->name, col->whint, flags);
if (cl == NULL) {
@@ -891,6 +894,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -p, --task <pid> print process namespaces\n"), out);
fputs(_(" -r, --raw use the raw output format\n"), out);
fputs(_(" -u, --notruncate don't truncate text in columns\n"), out);
+ fputs(_(" -W, --nowrap don't use multi-line representation\n"), out);
fputs(_(" -t, --type <name> namespace type (mnt, net, ipc, user, pid, uts, cgroup)\n"), out);
fputs(USAGE_SEPARATOR, out);
@@ -920,6 +924,7 @@ int main(int argc, char *argv[])
{ "notruncate", no_argument, NULL, 'u' },
{ "version", no_argument, NULL, 'V' },
{ "noheadings", no_argument, NULL, 'n' },
+ { "nowrap", no_argument, NULL, 'W' },
{ "list", no_argument, NULL, 'l' },
{ "raw", no_argument, NULL, 'r' },
{ "type", required_argument, NULL, 't' },
@@ -988,6 +993,9 @@ int main(int argc, char *argv[])
enabling_netnsid = true;
break;
}
+ case 'W':
+ ls.no_wrap = 1;
+ break;
default:
errtryhelp(EXIT_FAILURE);
}
--
2.13.6
next prev parent reply other threads:[~2017-11-24 10:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 10:31 [PATCH v2 0/7] Add netnsid and nsfs columns to lsns Masatake YAMATO
2017-11-24 10:31 ` [PATCH v2 1/7] lsns: add netnsid column Masatake YAMATO
2017-11-24 10:31 ` [PATCH v2 2/7] lsns: disable netnsid column by default Masatake YAMATO
2017-11-24 10:31 ` [PATCH v2 3/7] lsns: add a case for testing netnsid column Masatake YAMATO
2017-11-24 10:31 ` [PATCH v2 4/7] lsns: add nsfs column Masatake YAMATO
2017-11-24 10:31 ` [PATCH 5/5] lsns: add a case for testing " Masatake YAMATO
2017-11-24 10:34 ` Masatake YAMATO
2017-11-24 10:31 ` Masatake YAMATO [this message]
2017-11-24 10:31 ` [PATCH v2 6/7] " Masatake YAMATO
2017-11-24 10:31 ` [PATCH v2 7/7] man: write about using multi-line in NSFS cell of lsns Masatake YAMATO
2017-11-24 12:04 ` [PATCH v2 0/7] Add netnsid and nsfs columns to lsns Karel Zak
2017-11-27 16:46 ` Karel Zak
2017-11-27 17:06 ` Masatake YAMATO
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171124103110.17077-7-yamato@redhat.com \
--to=yamato@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).