2002-12-18 22:57:05 +03:00
|
|
|
.\" $NetBSD: qsubst.1,v 1.3 2002/12/18 19:57:05 wiz Exp $
|
1999-09-04 21:07:22 +04:00
|
|
|
.\"
|
1999-09-04 21:04:05 +04:00
|
|
|
.\" This file is in the public domain.
|
1999-09-04 21:07:22 +04:00
|
|
|
.Dd September 4, 1999
|
1999-09-04 21:04:05 +04:00
|
|
|
.Dt QSUBST 1
|
1999-09-04 21:07:22 +04:00
|
|
|
.Os
|
1999-09-04 21:04:05 +04:00
|
|
|
.Sh NAME
|
|
|
|
.Nm qsubst
|
|
|
|
.Nd query-replace strings in files
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
|
|
|
.Ar str1
|
|
|
|
.Ar str2
|
|
|
|
.Op Ar flags
|
|
|
|
.Ar file
|
|
|
|
.Op Ar file Op Ar ...
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm
|
2002-12-18 22:57:05 +03:00
|
|
|
reads its options (see below) to get a list of files.
|
|
|
|
For each file on this list, it then replaces
|
1999-09-04 21:04:05 +04:00
|
|
|
.Ar str1
|
|
|
|
with
|
|
|
|
.Ar str2
|
|
|
|
wherever possible in that file, depending on user input (see below).
|
|
|
|
The result is written back onto the original file.
|
|
|
|
.Pp
|
|
|
|
For each potential substitution found, the user is prompted with a few
|
|
|
|
lines before and after the line containing the string to be
|
2002-12-18 22:57:05 +03:00
|
|
|
substituted.
|
|
|
|
The string itself is displayed using the terminal's standout mode, if any.
|
|
|
|
Then one character is read from the terminal.
|
1999-09-04 21:04:05 +04:00
|
|
|
This is then interpreted as follows (this is designed to be like Emacs'
|
|
|
|
query-replace-string):
|
1999-09-04 21:07:22 +04:00
|
|
|
.Bl -tag -width "space" -compact -offset indent
|
1999-09-04 21:04:05 +04:00
|
|
|
.It space
|
|
|
|
Replace this occurrence and go on to the next one.
|
|
|
|
.It \&.
|
2002-12-18 22:57:05 +03:00
|
|
|
Replace this occurrence and don't change any more in this file (i.e., go
|
1999-09-04 21:04:05 +04:00
|
|
|
on to the next file).
|
|
|
|
.It \&,
|
2002-12-18 22:57:05 +03:00
|
|
|
Tentatively replace this occurrence.
|
|
|
|
The lines as they would look if the substitution were made are printed out.
|
|
|
|
Then another character is read and it is used to decide the result as if
|
|
|
|
the tentative replacement had not happened.
|
1999-09-04 21:04:05 +04:00
|
|
|
.It n
|
|
|
|
Don't change this one; just go on to the next one.
|
|
|
|
.It \&^G
|
|
|
|
Don't change this one or any others in this file, but instead simply go
|
|
|
|
on to the next file.
|
|
|
|
.It \&!
|
|
|
|
Change the rest in this file without asking, then go on to the next
|
|
|
|
file (at which point qsubst will start asking again).
|
|
|
|
.It \&?
|
|
|
|
Print out the current filename and ask again.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The first two arguments to qsubst are always the string to replace and
|
2002-12-18 22:57:05 +03:00
|
|
|
the string to replace it with.
|
|
|
|
The options are as follows:
|
1999-09-04 21:07:22 +04:00
|
|
|
.Bl -tag -width "-F filename" -compact -offset indent
|
1999-09-04 21:04:05 +04:00
|
|
|
.It Fl w
|
|
|
|
The search string is considered as a C symbol; it must be bounded by
|
2002-12-18 22:57:05 +03:00
|
|
|
non-symbol characters.
|
|
|
|
This option toggles.
|
1999-09-04 21:04:05 +04:00
|
|
|
.Pf ( Sq w
|
|
|
|
for
|
|
|
|
.Sq word . )
|
|
|
|
.It Fl \&!
|
|
|
|
.It Fl go
|
|
|
|
.It Fl noask
|
|
|
|
Enter \&! mode automatically at the beginning of each file.
|
|
|
|
.It Fl nogo
|
|
|
|
.It Fl ask
|
|
|
|
Negate
|
2002-12-18 22:57:05 +03:00
|
|
|
.Fl go ,
|
1999-09-04 21:04:05 +04:00
|
|
|
that is, ask as usual.
|
|
|
|
.It Fl c Ns Ar N
|
2002-12-18 22:57:05 +03:00
|
|
|
(Where
|
|
|
|
.Ar N
|
|
|
|
is a number.)
|
|
|
|
Give
|
|
|
|
.Ar N
|
|
|
|
lines of context above and below the
|
1999-09-04 21:04:05 +04:00
|
|
|
line with the match when prompting the user.
|
|
|
|
.It Fl CA Ns Ar N
|
2002-12-18 22:57:05 +03:00
|
|
|
(Where
|
|
|
|
.Ar N
|
|
|
|
is a number.)
|
|
|
|
Give
|
|
|
|
.Ar N
|
|
|
|
lines of context above the line with the match when prompting the user.
|
1999-09-04 21:04:05 +04:00
|
|
|
.It Fl CB Ns Ar N
|
2002-12-18 22:57:05 +03:00
|
|
|
(Where
|
|
|
|
.Ar N
|
|
|
|
is a number.)
|
|
|
|
Give
|
|
|
|
.Ar N
|
|
|
|
lines of context below the line with the match when prompting the user.
|
1999-09-04 21:04:05 +04:00
|
|
|
.It Fl f Ar filename
|
|
|
|
The
|
|
|
|
.Ar filename
|
|
|
|
argument is one of the files qsubst should perform substitutions in.
|
|
|
|
.It Fl F Ar filename
|
|
|
|
.Nm
|
|
|
|
reads
|
|
|
|
.Ar filename
|
2002-12-18 22:57:05 +03:00
|
|
|
to get the names of files to perform substitutions in.
|
|
|
|
The names should appear one to a line.
|
1999-09-04 21:04:05 +04:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The default amount of context is
|
|
|
|
.Fl c2 ,
|
|
|
|
that is, two lines above and two lines below the line with the match.
|
|
|
|
.Pp
|
|
|
|
Arguments not beginning with a
|
|
|
|
.Fl \&
|
|
|
|
sign in the options field are implicitly preceded by
|
|
|
|
.Fl f .
|
|
|
|
Thus,
|
|
|
|
.Fl f
|
|
|
|
is really needed only when the file name begins with a
|
|
|
|
.Fl \&
|
|
|
|
sign.
|
|
|
|
.Pp
|
|
|
|
.Nm
|
2002-12-18 22:57:05 +03:00
|
|
|
reads its options in order and processes files as it gets them.
|
|
|
|
This means, for example, that a
|
1999-09-04 21:04:05 +04:00
|
|
|
.Fl go
|
|
|
|
will affect only files named after the
|
|
|
|
.Fl go .
|
|
|
|
.Pp
|
|
|
|
The most context you can get is ten lines each, above and below.
|
|
|
|
.Pp
|
|
|
|
.Ar str1
|
|
|
|
is limited to 512 characters; there is no limit on the size of
|
|
|
|
.Ar str2 .
|
|
|
|
Neither one may contain a NUL.
|
|
|
|
.Pp
|
|
|
|
NULs in the file may cause qsubst to make various mistakes.
|
|
|
|
.Pp
|
|
|
|
If any other program modifies the file while qsubst is running, all
|
|
|
|
bets are off.
|
2002-12-18 22:57:05 +03:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An der Mouse Aq mouse@rodents.montreal.qc.ca
|