X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=serializer.cpp;h=356094fde659f86715a730d76cf5801135782af0;hb=fd6198891d6fd9642effc0843fef6f23b991af3e;hp=7d4ce119fceff9683584dbc8898682e1e9c9662e;hpb=355ab0d214ee0f08fb44ebeafd70d5e93db84c10;p=plocate diff --git a/serializer.cpp b/serializer.cpp index 7d4ce11..356094f 100644 --- a/serializer.cpp +++ b/serializer.cpp @@ -32,7 +32,7 @@ void print_possibly_escaped(const string &str) if (print_nul) { printf("%s%c", str.c_str(), 0); return; - } else if (!stdout_is_tty) { + } else if (literal_printing || !stdout_is_tty) { printf("%s\n", str.c_str()); return; } @@ -56,6 +56,9 @@ void print_possibly_escaped(const string &str) break; // EOF. } else if (pwc < 32 || pwc == '\'' || pwc == '"' || pwc == '\\') { all_safe = false; + } else if (pwc == '`') { + // A rather odd case; ls quotes this but does not escape it. + all_safe = false; } else { ptr += ret; len -= ret; @@ -84,10 +87,11 @@ void print_possibly_escaped(const string &str) printf("?"); ++ptr; --len; + continue; } else if (ret == 0) { break; // EOF. } - if (*ptr < 32 || *ptr == '\'' || *ptr == '"' || *ptr == '\\') { + if ((unsigned char)*ptr < 32 || *ptr == '\'' || *ptr == '"' || *ptr == '\\') { if (!in_escaped_mode) { printf("'$'"); in_escaped_mode = true;