]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man1p/fc.1p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man1p / fc.1p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "FC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" fc
4 .SH NAME
5 fc \- process the command history list
6 .SH SYNOPSIS
7 .LP
8 \fBfc\fP \fB[\fP\fB-r\fP\fB][\fP\fB-e\fP \fIeditor\fP\fB]
9 [\fP\fIfirst\fP\fB[\fP\fIlast\fP\fB]]\fP\fB
10 .br
11 .sp
12 fc -l\fP\fB[\fP\fB-nr\fP\fB] [\fP\fIfirst\fP\fB[\fP\fIlast\fP\fB]]\fP\fB
13 .br
14 .sp
15 fc -s\fP\fB[\fP\fIold\fP\fB=\fP\fInew\fP\fB][\fP\fIfirst\fP\fB]\fP\fB\fP
16 \fB
17 .br
18 \fP
19 .SH DESCRIPTION
20 .LP
21 The \fIfc\fP utility shall list, or shall edit and re-execute, commands
22 previously entered to an interactive \fIsh\fP.
23 .LP
24 The command history list shall reference commands by number. The first
25 number in the list is selected arbitrarily. The
26 relationship of a number to its command shall not change except when
27 the user logs in and no other process is accessing the list,
28 at which time the system may reset the numbering to start the oldest
29 retained command at another number (usually 1). When the
30 number reaches an implementation-defined upper limit, which shall
31 be no smaller than the value in \fIHISTSIZE\fP or 32767
32 (whichever is greater), the shell may wrap the numbers, starting the
33 next command with a lower number (usually 1). However, despite
34 this optional wrapping of numbers, \fIfc\fP shall maintain the time-ordering
35 sequence of the commands. For example, if four
36 commands in sequence are given the numbers 32766, 32767, 1 (wrapped),
37 and 2 as they are executed, command 32767 is considered the
38 command previous to 1, even though its number is higher.
39 .LP
40 When commands are edited (when the \fB-l\fP option is not specified),
41 the resulting lines shall be entered at the end of the
42 history list and then re-executed by \fIsh\fP. The \fIfc\fP command
43 that caused the editing
44 shall not be entered into the history list. If the editor returns
45 a non-zero exit status, this shall suppress the entry into the
46 history list and the command re-execution. Any command line variable
47 assignments or redirection operators used with \fIfc\fP shall
48 affect both the \fIfc\fP command itself as well as the command that
49 results; for example:
50 .sp
51 .RS
52 .nf
53
54 \fBfc -s -- -1 2>/dev/null
55 \fP
56 .fi
57 .RE
58 .LP
59 reinvokes the previous command, suppressing standard error for both
60 \fIfc\fP and the previous command.
61 .SH OPTIONS
62 .LP
63 The \fIfc\fP utility shall conform to the Base Definitions volume
64 of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
65 .LP
66 The following options shall be supported:
67 .TP 7
68 \fB-e\ \fP \fIeditor\fP
69 Use the editor named by \fIeditor\fP to edit the commands. The \fIeditor\fP
70 string is a utility name, subject to search via
71 the \fIPATH\fP variable (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
72 Chapter 8, Environment Variables). The value in the \fIFCEDIT\fP variable
73 shall be used as a
74 default when \fB-e\fP is not specified. If \fIFCEDIT\fP is null or
75 unset, \fIed\fP shall be
76 used as the editor.
77 .TP 7
78 \fB-l\fP
79 (The letter ell.) List the commands rather than invoking an editor
80 on them. The commands shall be written in the sequence
81 indicated by the \fIfirst\fP and \fIlast\fP operands, as affected
82 by \fB-r\fP, with each command preceded by the command
83 number.
84 .TP 7
85 \fB-n\fP
86 Suppress command numbers when listing with \fB-l\fP.
87 .TP 7
88 \fB-r\fP
89 Reverse the order of the commands listed (with \fB-l\fP) or edited
90 (with neither \fB-l\fP nor \fB-s\fP).
91 .TP 7
92 \fB-s\fP
93 Re-execute the command without invoking an editor.
94 .sp
95 .SH OPERANDS
96 .LP
97 The following operands shall be supported:
98 .TP 7
99 \fIfirst\fP,\ \fIlast\fP
100 Select the commands to list or edit. The number of previous commands
101 that can be accessed shall be determined by the value of
102 the \fIHISTSIZE\fP variable. The value of \fIfirst\fP or \fIlast\fP
103 or both shall be one of the following:
104 .TP 7
105 \fB[+]\fP\fInumber\fP
106 .RS
107 A positive number representing a command number; command numbers can
108 be displayed with the \fB-l\fP option.
109 .RE
110 .TP 7
111 \fB-\fP\fInumber\fP
112 .RS
113 A negative decimal number representing the command that was executed
114 \fInumber\fP of commands previously. For example, -1 is
115 the immediately previous command.
116 .RE
117 .TP 7
118 \fIstring\fP
119 .RS
120 A string indicating the most recently entered command that begins
121 with that string. If the \fIold\fP= \fInew\fP operand is
122 not also specified with \fB-s\fP, the string form of the \fIfirst\fP
123 operand cannot contain an embedded equal sign.
124 .RE
125 .sp
126 .LP
127 When the synopsis form with \fB-s\fP is used:
128 .RS
129 .IP " *" 3
130 If \fIfirst\fP is omitted, the previous command shall be used.
131 .LP
132 .RE
133 .LP
134 For the synopsis forms without \fB-s\fP:
135 .RS
136 .IP " *" 3
137 If \fIlast\fP is omitted, \fIlast\fP shall default to the previous
138 command when \fB-l\fP is specified; otherwise, it shall
139 default to \fIfirst\fP.
140 .LP
141 .IP " *" 3
142 If \fIfirst\fP and \fIlast\fP are both omitted, the previous 16 commands
143 shall be listed or the previous single command shall
144 be edited (based on the \fB-l\fP option).
145 .LP
146 .IP " *" 3
147 If \fIfirst\fP and \fIlast\fP are both present, all of the commands
148 from \fIfirst\fP to \fIlast\fP shall be edited (without
149 \fB-l\fP) or listed (with \fB-l\fP). Editing multiple commands shall
150 be accomplished by presenting to the editor all of the
151 commands at one time, each command starting on a new line. If \fIfirst\fP
152 represents a newer command than \fIlast\fP, the
153 commands shall be listed or edited in reverse sequence, equivalent
154 to using \fB-r\fP. For example, the following commands on the
155 first line are equivalent to the corresponding commands on the second:
156 .sp
157 .RS
158 .nf
159
160 \fBfc -r 10 20 fc 30 40
161 fc 20 10 fc -r 40 30
162 \fP
163 .fi
164 .RE
165 .LP
166 .IP " *" 3
167 When a range of commands is used, it shall not be an error to specify
168 \fIfirst\fP or \fIlast\fP values that are not in the
169 history list; \fIfc\fP shall substitute the value representing the
170 oldest or newest command in the list, as appropriate. For
171 example, if there are only ten commands in the history list, numbered
172 1 to 10:
173 .sp
174 .RS
175 .nf
176
177 \fBfc -l
178 fc 1 99
179 \fP
180 .fi
181 .RE
182 .LP
183 shall list and edit, respectively, all ten commands.
184 .LP
185 .RE
186 .TP 7
187 \fIold\fP=\fInew\fP
188 Replace the first occurrence of string \fIold\fP in the commands to
189 be re-executed by the string \fInew\fP.
190 .sp
191 .SH STDIN
192 .LP
193 Not used.
194 .SH INPUT FILES
195 .LP
196 None.
197 .SH ENVIRONMENT VARIABLES
198 .LP
199 The following environment variables shall affect the execution of
200 \fIfc\fP:
201 .TP 7
202 \fIFCEDIT\fP
203 This variable, when expanded by the shell, shall determine the default
204 value for the \fB-e\fP \fIeditor\fP option's
205 \fIeditor\fP option-argument. If \fIFCEDIT\fP is null or unset, \fIed\fP
206 shall be used as the
207 editor.
208 .TP 7
209 \fIHISTFILE\fP
210 Determine a pathname naming a command history file. If the \fIHISTFILE\fP
211 variable is not set, the shell may attempt to access
212 or create a file \fB.sh_history\fP in the directory referred to by
213 the \fIHOME\fP environment variable. If the shell cannot
214 obtain both read and write access to, or create, the history file,
215 it shall use an unspecified mechanism that allows the history to
216 operate properly. (References to history "file" in this section shall
217 be understood to mean this unspecified mechanism in such
218 cases.) An implementation may choose to access this variable only
219 when initializing the history file; this initialization shall
220 occur when \fIfc\fP or \fIsh\fP first attempt to retrieve entries
221 from, or add entries to, the
222 file, as the result of commands issued by the user, the file named
223 by the \fIENV\fP variable, or implementation-defined system
224 start-up files. In some historical shells, the history file is initialized
225 just after the \fIENV\fP file has been processed.
226 Therefore, it is implementation-defined whether changes made to \fIHISTFILE\fP
227 after the history file has been initialized are
228 effective. Implementations may choose to disable the history list
229 mechanism for users with appropriate privileges who do not set
230 \fIHISTFILE ;\fP the specific circumstances under which this occurs
231 are implementation-defined. If more than one instance of the
232 shell is using the same history file, it is unspecified how updates
233 to the history file from those shells interact. As entries are
234 deleted from the history file, they shall be deleted oldest first.
235 It is unspecified when history file entries are physically
236 removed from the history file.
237 .TP 7
238 \fIHISTSIZE\fP
239 Determine a decimal number representing the limit to the number of
240 previous commands that are accessible. If this variable is
241 unset, an unspecified default greater than or equal to 128 shall be
242 used. The maximum number of commands in the history list is
243 unspecified, but shall be at least 128. An implementation may choose
244 to access this variable only when initializing the history
245 file, as described under \fIHISTFILE .\fP Therefore, it is unspecified
246 whether changes made to \fIHISTSIZE\fP after the history
247 file has been initialized are effective.
248 .TP 7
249 \fILANG\fP
250 Provide a default value for the internationalization variables that
251 are unset or null. (See the Base Definitions volume of
252 IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables
253 for
254 the precedence of internationalization variables used to determine
255 the values of locale categories.)
256 .TP 7
257 \fILC_ALL\fP
258 If set to a non-empty string value, override the values of all the
259 other internationalization variables.
260 .TP 7
261 \fILC_CTYPE\fP
262 Determine the locale for the interpretation of sequences of bytes
263 of text data as characters (for example, single-byte as
264 opposed to multi-byte characters in arguments and input files).
265 .TP 7
266 \fILC_MESSAGES\fP
267 Determine the locale that should be used to affect the format and
268 contents of diagnostic messages written to standard
269 error.
270 .TP 7
271 \fINLSPATH\fP
272 Determine the location of message catalogs for the processing of \fILC_MESSAGES
273 \&.\fP
274 .sp
275 .SH ASYNCHRONOUS EVENTS
276 .LP
277 Default.
278 .SH STDOUT
279 .LP
280 When the \fB-l\fP option is used to list commands, the format of each
281 command in the list shall be as follows:
282 .sp
283 .RS
284 .nf
285
286 \fB"%d\\t%s\\n", <\fP\fIline number\fP\fB>, <\fP\fIcommand\fP\fB>
287 \fP
288 .fi
289 .RE
290 .LP
291 If both the \fB-l\fP and \fB-n\fP options are specified, the format
292 of each command shall be:
293 .sp
294 .RS
295 .nf
296
297 \fB"\\t%s\\n", <\fP\fIcommand\fP\fB>
298 \fP
299 .fi
300 .RE
301 .LP
302 If the <\fIcommand\fP> consists of more than one line, the lines after
303 the first shall be displayed as:
304 .sp
305 .RS
306 .nf
307
308 \fB"\\t%s\\n", <\fP\fIcontinued-command\fP\fB>
309 \fP
310 .fi
311 .RE
312 .SH STDERR
313 .LP
314 The standard error shall be used only for diagnostic messages.
315 .SH OUTPUT FILES
316 .LP
317 None.
318 .SH EXTENDED DESCRIPTION
319 .LP
320 None.
321 .SH EXIT STATUS
322 .LP
323 The following exit values shall be returned:
324 .TP 7
325 \ 0
326 Successful completion of the listing.
327 .TP 7
328 >0
329 An error occurred.
330 .sp
331 .LP
332 Otherwise, the exit status shall be that of the commands executed
333 by \fIfc\fP.
334 .SH CONSEQUENCES OF ERRORS
335 .LP
336 Default.
337 .LP
338 \fIThe following sections are informative.\fP
339 .SH APPLICATION USAGE
340 .LP
341 Since editors sometimes use file descriptors as integral parts of
342 their editing, redirecting their file descriptors as part of
343 the \fIfc\fP command can produce unexpected results. For example,
344 if \fIvi\fP is the
345 \fIFCEDIT\fP editor, the command:
346 .sp
347 .RS
348 .nf
349
350 \fBfc -s | more
351 \fP
352 .fi
353 .RE
354 .LP
355 does not work correctly on many systems.
356 .LP
357 Users on windowing systems may want to have separate history files
358 for each window by setting \fIHISTFILE\fP as follows:
359 .sp
360 .RS
361 .nf
362
363 \fBHISTFILE=$HOME/.sh_hist$$
364 \fP
365 .fi
366 .RE
367 .SH EXAMPLES
368 .LP
369 None.
370 .SH RATIONALE
371 .LP
372 This utility is based on the \fIfc\fP built-in of the KornShell.
373 .LP
374 An early proposal specified the \fB-e\fP option as \fB[-e\fP \fIeditor\fP
375 \fB[\fP \fIold\fP = \fInew\fP \fB]]\fP, which
376 is not historical practice. Historical practice in \fIfc\fP of either
377 \fB[-e\fP \fIeditor\fP \fB]\fP or \fB[-e - [\fP
378 \fIold\fP = \fInew\fP \fB]]\fP is acceptable, but not both together.
379 To clarify this, a new option \fB-s\fP was introduced
380 replacing the \fB[-e -]\fP. This resolves the conflict and makes \fIfc\fP
381 conform to the Utility Syntax Guidelines.
382 .TP 7
383 \fIHISTFILE\fP
384 Some implementations of the KornShell check for the superuser and
385 do not create a history file unless \fIHISTFILE\fP is set.
386 This is done primarily to avoid creating unlinked files in the root
387 file system when logging in during single-user mode.
388 \fIHISTFILE\fP must be set for the superuser to have history.
389 .TP 7
390 \fIHISTSIZE\fP
391 Needed to limit the size of history files. It is the intent of the
392 standard developers that when two shells share the same
393 history file, commands that are entered in one shell shall be accessible
394 by the other shell. Because of the difficulties of
395 synchronization over a network, the exact nature of the interaction
396 is unspecified.
397 .sp
398 .LP
399 The initialization process for the history file can be dependent on
400 the system start-up files, in that they may contain commands
401 that effectively preempt the settings the user has for \fIHISTFILE\fP
402 and \fIHISTSIZE .\fP For example, function definition
403 commands are recorded in the history file. If the system administrator
404 includes function definitions in some system start-up file
405 called before the \fIENV\fP file, the history file is initialized
406 before the user can influence its characteristics. In some
407 historical shells, the history file is initialized just after the
408 \fIENV\fP file has been processed. Because of these situations,
409 the text requires the initialization process to be implementation-defined.
410 .LP
411 Consideration was given to omitting the \fIfc\fP utility in favor
412 of the command line editing feature in \fIsh\fP. For example, in \fIvi\fP
413 editing mode, typing
414 \fB"<ESC> v"\fP is equivalent to:
415 .sp
416 .RS
417 .nf
418
419 \fBEDITOR=vi fc
420 \fP
421 .fi
422 .RE
423 .LP
424 However, the \fIfc\fP utility allows the user the flexibility to edit
425 multiple commands simultaneously (such as \fIfc\fP 10
426 20) and to use editors other than those supported by \fIsh\fP for
427 command line editing.
428 .LP
429 In the KornShell, the alias \fBr\fP (``re-do") is preset to \fIfc\fP
430 \fB-e -\fP (equivalent to the POSIX \fIfc\fP
431 \fB-s\fP). This is probably an easier command name to remember than
432 \fIfc\fP (``fix command"), but it does not meet the Utility
433 Syntax Guidelines. Renaming \fIfc\fP to \fIhist\fP or \fIredo\fP was
434 considered, but since this description closely matches
435 historical KornShell practice already, such a renaming was seen as
436 gratuitous. Users are free to create aliases whenever odd
437 historical names such as \fIfc\fP, \fIawk\fP, \fIcat\fP,
438 \fIgrep\fP, or \fIyacc\fP are standardized by
439 POSIX.
440 .LP
441 Command numbers have no ordering effects; they are like serial numbers.
442 The \fB-r\fP option and -\fInumber\fP operand address
443 the sequence of command execution, regardless of serial numbers. So,
444 for example, if the command number wrapped back to 1 at some
445 arbitrary point, there would be no ambiguity associated with traversing
446 the wrap point. For example, if the command history
447 were:
448 .sp
449 .RS
450 .nf
451
452 \fB32766: echo 1
453 32767: echo 2
454 1: echo 3
455 \fP
456 .fi
457 .RE
458 .LP
459 the number -2 refers to command 32767 because it is the second previous
460 command, regardless of serial number.
461 .SH FUTURE DIRECTIONS
462 .LP
463 None.
464 .SH SEE ALSO
465 .LP
466 \fIsh\fP
467 .SH COPYRIGHT
468 Portions of this text are reprinted and reproduced in electronic form
469 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
470 -- Portable Operating System Interface (POSIX), The Open Group Base
471 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
472 Electrical and Electronics Engineers, Inc and The Open Group. In the
473 event of any discrepancy between this version and the original IEEE and
474 The Open Group Standard, the original IEEE and The Open Group Standard
475 is the referee document. The original Standard can be obtained online at
476 http://www.opengroup.org/unix/online.html .