/
insitu.1
55 lines (51 loc) · 1.44 KB
/
insitu.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.TH INSITU 1 insitu\-1.0
.SH NAME
insitu \- modify files in place with shell commands
.SH SYNOPSIS
.nh
insitu
[\fB\-t\fR] file command
.SH DESCRIPTION
A shell pipeline cannot both read and write to the same file; for
example
.nf
cat foo | grep bar > foo
.fi
will merely delete the contents of foo.
Insitu wraps a shell command, connecting its standard input and
standard output to the file. If
.I command
finishes successfully, the file will be truncated (or extended) to the
size of the output produced by the command. If
.I command
returns a non-zero exit status, the file will not be truncated (unless
-t is passed), but contain the output read from the command, followed
by the rest of the original file. The part of the file overwritten by
the command output will be lost.
Insitu runs the command with '$SHELL -c \fIcommand\fR', substituting
/bin/sh for $SHELL if the latter is not set.
.SS Options
.TP
.B \-t
truncate \fIfile\fR even if
.I command
returns a non-zero exit status.
.SH EXIT STATUS
insitu returns the exit status of \fIcommand\fR.
Additionally,
.B 128
is returned if invalid flags are passed,
.B 129
if
.I file
cannot be accessed, and
.B 130
if the child process for running
.I command
cannot be started.
.SH BUGS
Insitu is a dangerous and brittle tool that can easily cause data
corruption if the command fails halfway through. Make sure you
understand this risk before running it on important files.
.SH SEE ALSO
.BR cp (1), mv (1), sh (1)