- if (event != GUESTFS_EVENT_APPLIANCE)
- ignore_value (write (STDERR_FILENO, nl, strlen (nl)));
+ for (i = 0; i < buf_len; ++i) {
+ c = buf[i];
+ if (c_isprint (c) || (from_appliance && (c == '\n' || c == '\r')))
+ putc (c, stderr);
+ else {
+ switch (c) {
+ case '\0': fputs ("\\0", stderr); break;
+ case '\a': fputs ("\\a", stderr); break;
+ case '\b': fputs ("\\b", stderr); break;
+ case '\f': fputs ("\\f", stderr); break;
+ case '\n': fputs ("\\n", stderr); break;
+ case '\r': fputs ("\\r", stderr); break;
+ case '\t': fputs ("\\t", stderr); break;
+ case '\v': fputs ("\\v", stderr); break;
+ default:
+ fprintf (stderr, "\\x%x", (unsigned) c);
+ }
+ }
+ }
+
+ if (!from_appliance)
+ putc ('\n', stderr);