From c0b2650acab9ec0aa1ab9473bf422afa920ed262 Mon Sep 17 00:00:00 2001 From: Stanislav Brabec Date: Wed, 28 Feb 2024 15:06:14 +0100 Subject: [PATCH] setterm: Document behavior of redirection Debugging an error of setterm, I realized that setterm --powerdown operates on stdout but setterm --powersave operates on stdin. Such unexpected behavior should be documented. I prefer a less accurate generic "always redirect both stdin and stdout" over recommending of the correct I/O stream for each option separately. Signed-off-by: Stanislav Brabec (cherry picked from commit 4aa584a0e7482b89599c01986cd4ea69a397f808) --- term-utils/setterm.1.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/term-utils/setterm.1.adoc b/term-utils/setterm.1.adoc index 880fe10d63..365c4bb009 100644 --- a/term-utils/setterm.1.adoc +++ b/term-utils/setterm.1.adoc @@ -156,6 +156,10 @@ Turns underline mode on or off. include::man-common/help-version.adoc[] +== WARNING + +Use of *setterm* in combination with stdout redirection can have unexpected results, as some options operate on stdin. To prevent problems, always redirect both stdin and stdout to the same device. + == COMPATIBILITY Since version 2.25 *setterm* has support for long options with two hyphens, for example *--help*, beside the historical long options with a single hyphen, for example *-help*. In scripts it is better to use the backward-compatible single hyphen rather than the double hyphen. Currently there are no plans nor good reasons to discontinue single-hyphen compatibility. -- 2.47.3