.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "edinplace 1" .TH edinplace 1 "2018-10-09" "Mail Avenger 0.8.5" "Mail Avenger 0.8.5" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" edinplace \- edit a file in place .SH "SYNOPSIS" .IX Header "SYNOPSIS" edinplace [\-\-error=\fIcode\fR] [[\-\-file=\fIfile\fR] \fIcommand\fR [\fIarg\fR ...]] .SH "DESCRIPTION" .IX Header "DESCRIPTION" edinplace runs \fIcommand\fR with its input from \fIfile\fR (or standard input by default), and then replaces the contents of \fIfile\fR with the output of \fIcommand\fR. To the extent possible, edinplace attempts to exit with the same status as \fIcommand\fR. .PP If edinplace is run on standard input (no \fB\-\-file\fR option), it must inherit a file descriptor 0 that is open for both reading and writing. When processing standard input, if edinplace does not encounter a fatal error, it rewinds its standard input to offset 0 before exiting. Thus, a script can first run \fBedinplace\fR \fIcommand\fR, then run another filter command such as \fBgrep\fR, and the resulting output will be the output of grep on \fIcommand\fR's output. .PP If no \fIcommand\fR is specified, edinplace just rewinds its standard input to file offset 0. In this case, it is an error to supply the \&\fB\-\-file\fR option. Of course, rewinding only works when standard input is a real file (as opposed to a pipe or device). .PP There are two options: .IP "\fB\-\-error=\fR\fIcode\fR (\fB\-x\fR \fIcode\fR)" 4 .IX Item "--error=code (-x code)" Ordinarily, edinplace attempts to exit with the same status as \&\fIcommand\fR. However, if edinplace encounters some fatal error (such as being unable to execute \fIcommand\fR), it will exit with status \&\fIcode\fR. The default value is 1. The range of valid exit codes is 1\-255, inclusive. .IP "\fB\-\-file=\fR\fIfile\fR (\fB\-f\fR \fIfile\fR)" 4 .IX Item "--file=file (-f file)" Specifies that \fIfile\fR should be edited. Otherwise, edinplace will edit its standard input (which must be opened for both reading and writing). .IP "\fB\-\-skipfrom\fR" 4 .IX Item "--skipfrom" Skip the first line of the file if it starts \*(L"From \*(R". If edinplace is run without a command, positions the file offset at the start of the second line of the file. If edinplace is run with a command, then the first line of the file is neither fed to the command, nor overwritten. This option is useful for running edinplace over mail files, which sometimes start with a \*(L"From \*(R" line specifying the envelope sender of the message. Since \*(L"From \*(R" is not part of the message header, just a Unix convention, some programs are confused by the presence of that line. Note that if you specify a command, then edinplace resets the file offset to 0 upon exiting, even if the \fB\-\-skipfrom\fR option was present. .SH "EXAMPLES" .IX Header "EXAMPLES" The following command prepends the string \f(CW\*(C`ORIGINAL: \*(C'\fR to the beginning of each line in text file \fImessage\fR: .Sp .RS 4 \&\fBedinplace \-f message sed \-e 's/^/ORIGINAL: /'\fR .RE .PP The following command runs the \fBspamassassin\fR mail filter program on a mail message stored in file \fImessage\fR, replacing the contents of \&\fImessage\fR with \fBspamassassin\fR's annotated output, and exiting with code 100 if \fBspamassassin\fR thinks the message is spam. If edinplace encounters any fatal errors, it will exit with code 111. .Sp .RS 4 \&\fBedinplace \-x 111 \-f message spamassassin \-e 100\fR .RE .PP (\fBspamassassin\fR reads a mail message on standard input and outputs an annotated copy of the message including information about whether or not the message is likely to be spam and why. The \fB\-e\fR option to \&\fBspamassassin\fR specifies what exit status \fBspamassassin\fR should use if the message appears to be spam; edinplace will use the same exit code as the program it has run.) .PP To run spamassassin on incoming mail before accepting the mail from the remote client, place the following line in an appropriate Mail Avenger \fIrcpt\fR file as the last command executed: .PP .Vb 1 \& bodytest edinplace \-x 111 spamassassin \-e 100 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBavenger\fR\|(1) .PP The Mail Avenger home page: . .SH "BUGS" .IX Header "BUGS" edinplace does not make a copy of the file being edited, but rather overwrites the file as it is being processed. At any point where \&\fIcommand\fR has produced more output than it has consumed input from the file, edinplace buffers the difference in memory. Thus, a \&\fIcommand\fR that outputs large amounts of data before reading the input file can run edinplace out of memory. (A program that outputs data as it reads even a very large file should be fine, however.) .PP If \fIcommand\fR crashes or malfunctions for any reason, you will likely lose the input file, since edinplace will view this as a program that simply outputs the empty file. .SH "AUTHOR" .IX Header "AUTHOR" David Mazie\*`res