1*4da37b8eSschwarze.\" $OpenBSD: fmt.1,v 1.30 2016/10/24 13:46:58 schwarze Exp $ 2df930be7Sderaadt.\" 3df930be7Sderaadt.\" Copyright (c) 1980, 1990, 1993 4df930be7Sderaadt.\" The Regents of the University of California. All rights reserved. 5df930be7Sderaadt.\" 6df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without 7df930be7Sderaadt.\" modification, are permitted provided that the following conditions 8df930be7Sderaadt.\" are met: 9df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright 10df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer. 11df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright 12df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer in the 13df930be7Sderaadt.\" documentation and/or other materials provided with the distribution. 14f75387cbSmillert.\" 3. Neither the name of the University nor the names of its contributors 15df930be7Sderaadt.\" may be used to endorse or promote products derived from this software 16df930be7Sderaadt.\" without specific prior written permission. 17df930be7Sderaadt.\" 18df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21df930be7Sderaadt.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28df930be7Sderaadt.\" SUCH DAMAGE. 29df930be7Sderaadt.\" 30df930be7Sderaadt.\" @(#)fmt.1 8.1 (Berkeley) 6/6/93 31df930be7Sderaadt.\" 32*4da37b8eSschwarze.Dd $Mdocdate: October 24 2016 $ 33df930be7Sderaadt.Dt FMT 1 34df930be7Sderaadt.Os 35df930be7Sderaadt.Sh NAME 36df930be7Sderaadt.Nm fmt 37df930be7Sderaadt.Nd simple text formatter 38df930be7Sderaadt.Sh SYNOPSIS 39c3444d0bSaaron.Nm fmt 40ae00fe5fSmillert.Op Fl cmnps 41dce78b8dSmillert.Op Fl d Ar chars 42ea050599Sjmc.Op Fl l Ar number 43ea050599Sjmc.Op Fl t Ar number 44ba2afd26Sschwarze.Op Ar goal Oo Ar maximum Oc | Fl Ar width | Fl w Ar width 45ea050599Sjmc.Op Ar 46df930be7Sderaadt.Sh DESCRIPTION 47581190f2Saaron.Nm 48df930be7Sderaadtis a simple text formatter which reads the concatenation of input 49df930be7Sderaadtfiles (or standard input if none are given) and produces on standard 50df930be7Sderaadtoutput a version of its input with lines as close to the 51df930be7Sderaadt.Ar goal 52df930be7Sderaadtlength 53dce78b8dSmillertas possible without exceeding the 54dce78b8dSmillert.Ar maximum . 55dce78b8dSmillertThe 56df930be7Sderaadt.Ar goal 57df930be7Sderaadtlength defaults 58dce78b8dSmillertto 65 and the 59dce78b8dSmillert.Ar maximum 608557a8e4Smillertto 10 more than the 618557a8e4Smillert.Ar goal 628557a8e4Smillertlength. 63cb267520Sjmc.Pp 64518a5964SpjanzenAlternatively, a single 65518a5964Spjanzen.Ar width 66518a5964Spjanzenparameter can be specified either by prepending a hyphen to it or by using 67518a5964Spjanzen.Fl w . 68518a5964SpjanzenFor example, 69cb267520Sjmc.Dq fmt -w 72 , 70cb267520Sjmc.Dq fmt -72 , 71518a5964Spjanzenand 72cb267520Sjmc.Dq fmt 72 72 73518a5964Spjanzenall produce identical output. 74453cecf0SaaronThe spacing at the beginning of the input lines is preserved in the output, 75453cecf0Saaronas are blank lines and interword spacing. 76518a5964SpjanzenLines are joined or split only at white space; that is, words are never 77518a5964Spjanzenjoined or hyphenated. 78df930be7Sderaadt.Pp 798cf461a5SaaronThe options are as follows: 80f1ba3473Saaron.Bl -tag -width Ds 81dce78b8dSmillert.It Fl c 82453cecf0SaaronCenter the text, line by line. 83453cecf0SaaronIn this case, most of the other 84dce78b8dSmillertoptions are ignored; no splitting or joining of lines is done. 85ea050599Sjmc.It Fl d Ar chars 86cb267520SjmcTreat 87ea050599Sjmc.Ar chars 88ea050599Sjmc(and no others) as sentence-ending characters. 89ea050599SjmcBy default the 90ea050599Sjmcsentence-ending characters are full stop 91ea050599Sjmc.Pq Ql \&. , 92ea050599Sjmcquestion mark 93cb267520Sjmc.Pq Ql \&? , 94ea050599Sjmcand exclamation mark 95ea050599Sjmc.Pq Ql \&! . 96ea050599SjmcRemember that some characters may need to be 97cb267520Sjmcescaped to protect them from the shell. 98ea050599Sjmc.It Fl l Ar number 99ea050599SjmcReplace multiple spaces with tabs at the start of each output 100ea050599Sjmcline, if possible. 101ea050599Sjmc.Ar number 102ea050599Sjmcspaces will be replaced with one tab. 103dce78b8dSmillert.It Fl m 104dce78b8dSmillertTry to format mail header lines contained in the input sensibly. 105ae00fe5fSmillert.It Fl n 106ae00fe5fSmillertFormat lines beginning with a 107ae00fe5fSmillert.Ql \&. 108ae00fe5fSmillert(dot) character. 109ae00fe5fSmillertNormally, 110ae00fe5fSmillert.Nm 111a1df064dSjmcdoes not fill these lines, 112a1df064dSjmcfor compatibility with troff and nroff. 113dce78b8dSmillert.It Fl p 114453cecf0SaaronAllow indented paragraphs. 115453cecf0SaaronWithout the 116dce78b8dSmillert.Fl p 117dce78b8dSmillertflag, any change in the amount of whitespace at the start of a line 118dce78b8dSmillertresults in a new paragraph being begun. 119dce78b8dSmillert.It Fl s 120dce78b8dSmillertCollapse whitespace inside lines, so that multiple whitespace 121cb267520Sjmccharacters are turned into a single space 122cb267520Sjmc(or, at the end of a 123cb267520Sjmcsentence, a double space). 124dce78b8dSmillert.It Fl t Ar number 125dce78b8dSmillertAssume that the input files' tabs assume 126dce78b8dSmillert.Ar number 127453cecf0Saaronspaces per tab stop. 128453cecf0SaaronThe default is 8. 129dce78b8dSmillert.El 130368e9f69Smillert.Pp 131581190f2Saaron.Nm 132df930be7Sderaadtis meant to format mail messages prior to sending, but may also be useful 133df930be7Sderaadtfor other simple tasks. 134df930be7SderaadtFor instance, 1352f160fa7Sjmcwithin an editor such as 1362f160fa7Sjmc.Xr vi 1 , 1372f160fa7Sjmcthe following command 138df930be7Sderaadtwill reformat a paragraph, 1392f160fa7Sjmcevening the lines: 1402f160fa7Sjmc.Pp 1412f160fa7Sjmc.Dl !}fmt 142ef75aaf1Sschwarze.Sh ENVIRONMENT 143ef75aaf1Sschwarze.Bl -tag -width LC_CTYPE 144ef75aaf1Sschwarze.It Ev LC_CTYPE 145*4da37b8eSschwarzeThe character encoding 146ef75aaf1Sschwarze.Xr locale 1 . 147*4da37b8eSschwarzeIt decides which byte sequences form characters 148*4da37b8eSschwarzeand what their display width is. 149*4da37b8eSschwarzeIf unset or set to 150ef75aaf1Sschwarze.Qq C , 151ef75aaf1Sschwarze.Qq POSIX , 152*4da37b8eSschwarzeor an unsupported value, each byte except the tab 153*4da37b8eSschwarzeis treated as a character of display width 1. 154ef75aaf1Sschwarze.El 1555ad508d7Sschwarze.Sh EXIT STATUS 1565ad508d7Sschwarze.Ex -std 1575ad508d7SschwarzeThe latter happens with invalid options, insufficient memory, 1585ad508d7Sschwarzeor when an input file is not found or not readable. 15925fee5dbSjmcThe >0 exit value is the sum of all errors up to a maximum of 127; 16086106aaeSlummore errors may occur but the counter will only increment to this number. 161df930be7Sderaadt.Sh SEE ALSO 1622f160fa7Sjmc.Xr indent 1 , 163dce78b8dSmillert.Xr mail 1 , 1642f160fa7Sjmc.Xr vi 1 165df930be7Sderaadt.Sh HISTORY 1668557a8e4SmillertThe 167dce78b8dSmillert.Nm 1685ad508d7Sschwarzecommand first appeared in 1695ad508d7Sschwarze.Bx 2 . 170dce78b8dSmillert.Pp 171dce78b8dSmillertThe version described herein is a complete rewrite and appeared in 172453cecf0Saaron.Ox 2.4 . 1738557a8e4Smillert.Sh AUTHORS 1748557a8e4Smillert.An Kurt Shoens 1755ad508d7Sschwarze(July 1978) 1768557a8e4Smillert.An Liz Allen 1778557a8e4Smillert(added goal length concept) 1788557a8e4Smillert.An Gareth McCaughan 1798557a8e4Smillert(wrote this version) 180df930be7Sderaadt.Sh BUGS 181cb267520SjmcThe program was designed to be simple and fast \(en for more complex 182df930be7Sderaadtoperations, the standard text processors are likely to be more appropriate. 183dce78b8dSmillert.Pp 184dce78b8dSmillertWhen the first line of an indented paragraph is very long (more than 185dce78b8dSmillertabout twice the goal length), the indentation in the output can be 186dce78b8dSmillertwrong. 187dce78b8dSmillert.Pp 188dce78b8dSmillert.Nm 189dce78b8dSmillertis not infallible in guessing what lines are mail headers and what 190dce78b8dSmillertlines are not. 191