xref: /freebsd/contrib/vis/vis.1 (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1.\"	$NetBSD: vis.1,v 1.25 2021/02/20 09:31:51 nia Exp $
2.\"
3.\" Copyright (c) 1989, 1991, 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)vis.1	8.4 (Berkeley) 4/19/94
31.\"
32.Dd February 18, 2021
33.Dt VIS 1
34.Os
35.Sh NAME
36.Nm vis
37.Nd display non-printable characters in a visual format
38.Sh SYNOPSIS
39.Nm
40.Op Fl bcfhlMmNnoSstw
41.Op Fl e Ar extra
42.Op Fl F Ar foldwidth
43.Op Ar file ...
44.Sh DESCRIPTION
45.Nm
46is a filter for converting non-printable characters
47into a visual representation.
48It differs from
49.Ql cat -v
50in that
51the form is unique and invertible.
52By default, all non-graphic
53characters except space, tab, and newline are encoded.
54A detailed description of the
55various visual formats is given in
56.Xr vis 3 .
57.Pp
58The options are as follows:
59.Bl -tag -width Ds
60.It Fl b
61Turns off prepending of backslash before up-arrow control sequences
62and meta characters, and disables the doubling of backslashes.
63This
64produces output which is neither invertible or precise, but does
65represent a minimum of change to the input.
66It is similar to
67.Dq Li cat -v .
68.Pq Dv VIS_NOSLASH
69.It Fl c
70Request a format which displays a small subset of the
71non-printable characters using C-style backslash sequences.
72.Pq Dv VIS_CSTYLE
73.It Fl e Ar extra
74Also encode characters in
75.Ar extra ,
76per
77.Xr svis 3 .
78.It Fl F Ar foldwidth
79Causes
80.Nm
81to fold output lines to foldwidth columns (default 80), like
82.Xr fold 1 ,
83except
84that a hidden newline sequence is used, (which is removed
85when inverting the file back to its original form with
86.Xr unvis 1 ) .
87If the last character in the encoded file does not end in a newline,
88a hidden newline sequence is appended to the output.
89This makes
90the output usable with various editors and other utilities which
91typically don't work with partial lines.
92.It Fl f
93Same as
94.Fl F .
95.It Fl h
96Encode using the URI encoding from RFC 1808.
97.Pq Dv VIS_HTTPSTYLE
98.It Fl l
99Mark newlines with the visible sequence
100.Ql \e$ ,
101followed by the newline.
102.It Fl M
103Encode all shell meta characters (implies
104.Fl S ,
105.Fl w ,
106.Fl g )
107.Pq Dv VIS_META
108.It Fl m
109Encode using the MIME Quoted-Printable encoding from RFC 2045.
110.Pq Dv VIS_MIMESTYLE
111.It Fl N
112Turn on the
113.Dv VIS_NOLOCALE
114flag which encodes using the
115.Dq C
116locale, removing any encoding dependencies caused by the current
117locale settings specified in the environment.
118.It Fl n
119Turns off any encoding, except for the fact that backslashes are
120still doubled and hidden newline sequences inserted if
121.Fl f
122or
123.Fl F
124is selected.
125When combined with the
126.Fl f
127flag,
128.Nm
129becomes like
130an invertible version of the
131.Xr fold 1
132utility.
133That is, the output can be unfolded by running the output through
134.Xr unvis 1 .
135.It Fl o
136Request a format which displays non-printable characters as
137an octal number, \eddd.
138.Pq Dv VIS_OCTAL
139.It Fl S
140Encode shell meta-characters that are non-white space or glob.
141.Pq Dv VIS_SHELL
142.It Fl s
143Only characters considered unsafe to send to a terminal are encoded.
144This flag allows backspace, bell, and carriage return in addition
145to the default space, tab and newline.
146.Pq Dv VIS_SAFE
147.It Fl t
148Tabs are also encoded.
149.Pq Dv VIS_TAB
150.It Fl w
151White space (space-tab-newline) is also encoded.
152.Pq Dv VIS_WHITE
153.El
154.Sh MULTIBYTE CHARACTER SUPPORT
155.Nm
156supports multibyte character input.
157The encoding conversion is influenced by the setting of the
158.Ev LC_CTYPE
159environment variable which defines the set of characters that can be
160copied without encoding.
161.Pp
162When 8-bit data is present in the input,
163.Ev LC_CTYPE
164must be set to the correct locale or to the C locale.
165If the locales of the data and the conversion are mismatched, multibyte
166character recognition may fail and encoding will be performed byte-by-byte
167instead.
168.Sh ENVIRONMENT
169.Bl -tag -width ".Ev LC_CTYPE"
170.It Ev LC_CTYPE
171Specify the locale of the input data.
172Set to C if the input data locale is unknown.
173.El
174.Sh EXAMPLES
175Visualize characters encoding white spaces and tabs:
176.Bd -literal -offset indent
177$ echo -e "\\x10\\n\\t" | vis -w -t
178\\^P\\012\\011\\012
179.Ed
180.Pp
181Same as above but using `\\$' for newline followed by an actual newline:
182.Bd -literal -offset indent
183$ echo -e "\\x10\\n\\t" | vis -w -t -l
184\\^P\\$
185\\011\\$
186.Ed
187.Pp
188Visualize string using URI encoding:
189.Bd -literal -offset indent
190$ echo http://www.freebsd.org | vis -h
191http%3a%2f%2fwww.freebsd.org%0a
192.Ed
193.Sh SEE ALSO
194.Xr unvis 1 ,
195.Xr svis 3 ,
196.Xr vis 3
197.Sh HISTORY
198The
199.Nm
200command appears in
201.Bx 4.4 .
202Multibyte character support was added in
203.Nx 7.0
204and
205.Fx 9.2 .
206