Introduction
Introduction Statistics Contact Development Disclaimer Help
json2tsv.1: properly escape backslashes - json2tsv - JSON to TSV converter
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit e2eeb2664324786e1a51e0ce64dbe03eeeff8346
parent 2a02e40c0df8ea64f7cb59f15b867cdb1d9f6506
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 2 May 2022 20:16:47 +0200
json2tsv.1: properly escape backslashes
From the mdoc(7) extended introduction:
>To output a backslash, use the escape sequence \e. Never use the escape
sequence \\ in any context.
https://mandoc.bsd.lv/mdoc/intro/escaping.html
(Thanks adc for reporting it to sfeed so it came to my attention).
Diffstat:
M json2tsv.1 | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/json2tsv.1 b/json2tsv.1
@@ -1,4 +1,4 @@
-.Dd March 19, 2022
+.Dd May 2, 2022
.Dt JSON2TSV 1
.Os
.Sh NAME
@@ -41,17 +41,17 @@ separators can be specified in the following formats:
.Pp
.Bl -item -compact
.It
-\\\\ for a backslash character.
+\e\e for a backslash character.
.It
-\\n for a newline character.
+\en for a newline character.
.It
-\\r for a carriage return character.
+\er for a carriage return character.
.It
-\\t for a TAB character.
+\et for a TAB character.
.It
-\\xXX for a character specified in the hexadecimal format as XX.
+\exXX for a character specified in the hexadecimal format as XX.
.It
-\\NNN for a character specified in the octal format as NNN.
+\eNNN for a character specified in the octal format as NNN.
.El
.Pp
Otherwise: if a single character is specified this character will be used.
@@ -65,7 +65,7 @@ The output format per node is:
nodename<FIELD SEPARATOR>type<FIELD SEPARATOR>value<RECORD SEPARATOR>
.Ed
.Pp
-Control-characters such as a newline, TAB and backslash (\\n, \\t and \\\\) are
+Control-characters such as a newline, TAB and backslash (\en, \et and \e\e) are
escaped in the nodename and value fields unless a
.Fl F
or
@@ -104,7 +104,7 @@ exits with the exit status 0 on success, 1 on a parse error…
memory or a read/write error or 3 with an usage error.
.Sh EXAMPLES
.Bd -literal
-json2tsv < input.json | awk -F '\\t' '$1 == ".url" { print $3 }'
+json2tsv < input.json | awk -F '\et' '$1 == ".url" { print $3 }'
.Ed
.Pp
To filter without having to unescape characters the
@@ -119,10 +119,10 @@ Additionally the
.Fl r
option is used so control-characters are printed.
.Bd -literal
-json2tsv -r -F '\\x1f' -R '\\x1e' < input.json | \\
+json2tsv -r -F '\ex1f' -R '\ex1e' < input.json | \e
awk '
BEGIN {
- FS = "\\x1f"; RS = "\\x1e";
+ FS = "\ex1f"; RS = "\ex1e";
}
$1 == ".url" {
print $3;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.