patch for replacing non-printable chars in filenames

Paul Slootman paul at debian.org
Tue Nov 23 16:29:57 GMT 2004


There's a bug reported in Debian about the tty being screwed up by wierd
filenames, see http://bugs.debian.org/bug=242300

On the one hand, find will also do this. On the other hand, ls will
replace such chars with a question mark. Upon inspection, it appears to
be fairly simple to also do this in rsync (in the rwrite() function).

Here's a patch. Opinions? Perhaps don't do it unconditionally, i.e.
offer some way to turn it off?

Paul Slootman

--- log.c.orig	2004-10-04 11:51:37.000000000 +0200
+++ log.c	2004-11-23 17:27:29.000000000 +0100
@@ -180,6 +180,15 @@
 
 	buf[len] = 0;
 
+        if (code == FINFO) {
+            /* Replace non-printing chars in the string, most probably due to
+             * wierd filenames. Skip the first and last chars, they may be \n */
+            int i;
+            for (i=1; i<len-1; i++)
+                if (!isprint(buf[i]))
+                        buf[i] = '?';
+        }
+
 	if (am_server && msg_fd_out >= 0) {
 		/* Pass the message to our sibling. */
 		send_msg((enum msgcode)code, buf, len);


More information about the rsync mailing list