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;
}
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;
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;