coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-06 11:50:38
Commit6a8c357fc1af1f65bcb265bd30f78823496bd9a9
Parente8367edd416d339940811f92ab3a852730d574f0

tty: Fix "not a tty" message going to stderr

The POSIX standard for tty specifies that the "not a tty" message shall be output to standard out, not standard error.

Diffstat

M src/tty.c | 11 ++++++-----

1 files changed, 6 insertions, 5 deletions

diff --git a/src/tty.c b/src/tty.c
index e41e8c7..98a735f 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -1,4 +1,4 @@
-// tty.c, version 1.0.0
+// tty.c, version 1.1.0
 // OMKOV coreutils implementation of POSIX tty
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -17,12 +17,12 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
-
 #include <unistd.h>
 
+#include <stdio.h>
+
 int main(void) {
-	register char *tty = ttyname(fileno(stdin));
-	if (!tty) { error(1, "not a tty"); }
-	puts(tty); return 0;
+	char *tty = ttyname(fileno(stdin));
+	if (tty) { puts(tty); return 0; }
+	else { printf("not a tty\n"); return 1; }
 }