Browse Source

Output raw to standard error if it is not a terminal

Causal Agent 2 months ago
parent
commit
2a6e3f2d02
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
2 changed files with 5 additions and 0 deletions
  1. 3
    0
      catgirl.1
  2. 2
    0
      irc.c

+ 3
- 0
catgirl.1 View File

@@ -90,6 +90,9 @@ the same as the nickname.
90 90
 Show raw IRC protocol in the
91 91
 .Sy <raw>
92 92
 window.
93
+If standard error is not a terminal,
94
+output raw IRC protocol
95
+to standard error.
93 96
 .
94 97
 .It Fl w Ar pass
95 98
 Log in with

+ 2
- 0
irc.c View File

@@ -111,6 +111,7 @@ void ircFmt(const char *format, ...) {
111 111
 	va_end(ap);
112 112
 	if (!buf) err(EX_OSERR, "vasprintf");
113 113
 	if (self.raw) {
114
+		if (!isatty(STDERR_FILENO)) fprintf(stderr, "<<< %.*s\n", len - 2, buf);
114 115
 		uiFmt(TagRaw, UICold, "\3%d<<<\3 %.*s", IRCWhite, len - 2, buf);
115 116
 	}
116 117
 	ircWrite(buf, len);
@@ -142,6 +143,7 @@ retry:
142 143
 	while (NULL != (crlf = memmem(line, &buf[len] - line, "\r\n", 2))) {
143 144
 		crlf[0] = '\0';
144 145
 		if (self.raw) {
146
+			if (!isatty(STDERR_FILENO)) fprintf(stderr, ">>> %s\n", line);
145 147
 			uiFmt(TagRaw, UICold, "\3%d>>>\3 %s", IRCGray, line);
146 148
 		}
147 149
 		handle(line);

Loading…
Cancel
Save