[PATCH v2 1/1] paint visual host key with unicode box-drawing characters

Christian Hesse list at eworm.de
Tue Jul 7 18:17:56 AEST 2015


lists at wrant.com on Tue, 2015/07/07 05:43:
> A machine diff between one using ASCII and UTF-8 would yield not equal?

True. Do you need diffs of the artwork?
I suppose this broke several times in the past...

> Is it reasonable to only use UTF-8 ("pretty" chars) with a command line
> switch (forced) rather than as an override (implied) behaviour?

Just another idea... We could print unicode characters only when a real
terminal is detected.

From c3206e4182dea8877776c0d1f6f0e44149456a9a Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail at eworm.de>
Date: Tue, 7 Jul 2015 10:15:39 +0200
Subject: [PATCH 1/1] use unicode characters only when in real terminal

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 sshkey.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sshkey.c b/sshkey.c
index 326bc29..4c23483 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -46,6 +46,7 @@
 #include <resolv.h>
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
+#include <unistd.h>
 #endif /* HAVE_LOCALE_H */
 #ifdef HAVE_UTIL_H
 #include <util.h>
@@ -1122,7 +1123,8 @@ fingerprint_randomart(const char *alg, u_char *dgst_raw, size_t dgst_raw_len,
 
 	/* get locale for LC_CTYPE and decide about characters to use */
 	locale = setlocale(LC_CTYPE, NULL);
-	if (locale != NULL && *locale != 0 &&
+	if (isatty(fileno(stdout)) == 1 &&
+			locale != NULL && *locale != 0 &&
 			(strstr(locale, "UTF-8") ||
 			 strstr(locale, "utf-8") ||
 			 strstr(locale, "UTF8")  ||
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20150707/e3038fff/attachment.bin>


More information about the openssh-unix-dev mailing list