Draft:Unbuffer
Draft article not currently submitted for review.
This is a draft Articles for creation (AfC) submission. It is not currently pending review. While there are no deadlines, abandoned drafts may be deleted after six months. To edit the draft click on the "Edit" tab at the top of the window. To be accepted, a draft should:
It is strongly discouraged to write about yourself, your business or employer. If you do so, you must declare it. Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
Last edited by MarioGom (talk | contribs) 5 months ago. (Update) |
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
|
Unbuffer is a command for Unix-like systems that runs another command in a pseudoterminal (PTY) such as to have the effect that the command's standard output is directly connected to a terminal or terminal emulator. This can be useful to disable buffering, as per its namesake; it is also useful for commands that detect the output device and behave differently, to force the normal behaviour, such as to keep ANSI colour enabled even if output is being piped into another process/command. The unbuffer
command is written in Tool Command Language (Tcl) and is bundled with the Expect project.[1]
Examples[edit]
NVLC's lengthy help output produces colour-coded presentation of headings, options, and arguments to ease navigation and reading – but only if it detects that its stdout is connected to a terminal device, or something that behaves as such. Contrarily, it is common practice to pipe such lengthy output into a pager, such as less
, for example, to avoid flooding one's terminal. If NVLC detects that its output is a pipe then it disables its colour formatting, even though less
can display colour using the -R
option. To manage the lengthy output both with colour and with paging, the unbuffer
command can be employed, as follows:-
unbuffer nvlc --help | less -M -R
The ls
command (from GNU Coreutils, at least) supports the option --colour=always
, eliminating the need for unbuffer
in this instance. However, there are other behaviours of ls
for which unbuffer may still be useful, such as for its tabulation. Normally the output of ls
is tabulated, making better use of the full width of the terminal; but when piped, ls
disables its tabulation:-
$ ls --color=always /proc/ | head --lines=2 1 10
To restore the tabulation, unbuffer
can be applied in the same way as before:-
$ unbuffer ls --color=always /proc/ | head --lines=2 1 13971 18 2124 25516 31093 369 7104 90 kpagecount 10 14 1812 2126 25561 31972 3696 729 9025 kpageflags
References[edit]