Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man1 / unbuffer.1
CommitLineData
920dae64
AT
1.TH UNBUFFER 1 "1 June 1994"
2.SH NAME
3unbuffer \- unbuffer output
4.SH SYNOPSIS
5.B unbuffer
6.I program
7[
8.I args
9]
10.SH INTRODUCTION
11.B unbuffer
12disables the output buffering that occurs when program output
13is redirected from non-interactive programs.
14For example, suppose you are watching the output from a fifo by running it
15through od and then more.
16.nf
17
18 od -c /tmp/fifo | more
19
20.fi
21You will not see anything until a full page
22of output has been produced.
23
24You can disable this automatic buffering as follows:
25
26.nf
27
28 unbuffer od -c /tmp/fifo | more
29
30.fi
31Normally, unbuffer does not read from stdin. This simplifies use of unbuffer in some situations. To use unbuffer in a pipeline, use the -p flag.
32Example:
33.nf
34
35 process1 | unbuffer -p process2 | process3
36.fi
37.SH CAVEATS
38
39unbuffer -p may appear to work incorrectly if a process feeding input
40to unbuffer exits. Consider:
41.nf
42 process1 | unbuffer -p process2 | process3
43
44.fi
45If process1 exits, process2 may not yet have finished. It is
46impossible for unbuffer to know long to wait for process2 and process2
47may not ever finish, for example, if it is a filter. For expediency,
48unbuffer simply exits when it encounters an EOF from either its input
49or process2.
50
51In order to have a version of unbuffer that worked in all situations,
52an oracle would be necessary. If you want an application-specific
53solution, workarounds or hand-coded Expect may be more suitable. For
54example, the following example shows how to allow grep to finish
55processing when the cat before it finishes first. Using cat to feed
56grep would never require unbuffer in real life. It is merely a
57placeholder for some imaginary process that may or may not finish.
58Similarly, the final cat at the end of the pipeline is also a
59placeholder for another process.
60
61.nf
62
63$ cat /tmp/abcdef.log | grep abc | cat
64abcdef
65xxxabc defxxx
66$ cat /tmp/abcdef.log | unbuffer grep abc | cat
67$ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat
68abcdef
69xxxabc defxxx
70$
71.fi
72.SH BUGS
73
74The man page is longer than the program.
75
76.SH SEE ALSO
77.I
78"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
79\fRby Don Libes,
80O'Reilly and Associates, January 1995.
81.SH AUTHOR
82Don Libes, National Institute of Standards and Technology