From: Moshe Shemesh Date: Sun, 24 Nov 2019 16:02:38 +0000 (+0200) Subject: ip: fix oneline output X-Git-Tag: v5.5.0~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ccc3657406a4436a45884bdd55a02bd56af06fb;p=thirdparty%2Fiproute2.git ip: fix oneline output Ip tool oneline option should output each record on a single line. While oneline option is active the variable _SL_ replaces line feeds with the '\' character. However, at the end of print_linkinfo() the variable _SL_ shouldn't be used, otherwise the whole output is on a single line. Before this fix: $ip -o link 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\2: eth0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\ link/ether 52:54:00:60:0a:db brd ff:ff:ff:ff:ff:ff\3: eth1: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\ link/ether 00:50:56:1b:05:cd brd ff:ff:ff:ff:ff:ff\ After this fix: $ip -o link 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\ link/ether 52:54:00:60:0a:db brd ff:ff:ff:ff:ff:ff 3: eth1: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\ link/ether 00:50:56:1b:05:cd brd ff:ff:ff:ff:ff:ff Fixes: 3aa0e51be64b ("ip: add support for alternative name addition/deletion/list") Signed-off-by: Moshe Shemesh Reviewed-by: Jiri Pirko Signed-off-by: David Ahern --- diff --git a/ip/ipaddress.c b/ip/ipaddress.c index fe41bbef4..964f14df9 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1173,7 +1173,7 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) close_json_array(PRINT_JSON, NULL); } - print_string(PRINT_FP, NULL, "%s", _SL_); + print_string(PRINT_FP, NULL, "%s", "\n"); fflush(fp); return 1; }