ls: Print file name in quotes if it contains spaces

This commit is contained in:
Bananymous 2024-10-07 16:11:41 +03:00
parent 5bcfc9dd50
commit 5fa359c28d
1 changed files with 2 additions and 1 deletions

View File

@ -202,7 +202,8 @@ int list_directory(const BAN::String& path, config_t config)
{ {
if (i > 0) if (i > 0)
printf(" "); printf(" ");
printf("%s%s\e[m", entry_color(entries[i].st.st_mode), entries[i].name.data()); const char* format = entries[i].name.sv().contains(' ') ? "'%s%s\e[m'" : "%s%s\e[m";
printf(format, entry_color(entries[i].st.st_mode), entries[i].name.data());
} }
printf("\n"); printf("\n");
return ret; return ret;