diff --git a/bin/ls/extern.h b/bin/ls/extern.h index d6b420875c3f..7f480aac04f2 100644 --- a/bin/ls/extern.h +++ b/bin/ls/extern.h @@ -45,6 +45,7 @@ int revstatcmp(const FTSENT *, const FTSENT *); void printcol(DISPLAY *); void printlong(DISPLAY *); +int printname(const char *); void printscol(DISPLAY *); void printstream(DISPLAY *); void usage(void); diff --git a/bin/ls/ls.c b/bin/ls/ls.c index be19f3634a82..07ae82671368 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -470,10 +470,13 @@ traverse(int argc, char *argv[], int options) * a separator. If multiple arguments, precede each * directory with its name. */ - if (output) - (void)printf("\n%s:\n", p->fts_path); - else if (argc > 1) { - (void)printf("%s:\n", p->fts_path); + if (output) { + putchar('\n'); + printname(p->fts_path); + puts(":"); + } else if (argc > 1) { + printname(p->fts_path); + puts(":"); output = 1; } chp = fts_children(ftsp, ch_options); diff --git a/bin/ls/print.c b/bin/ls/print.c index 4f2907affe9f..ed8732343934 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -141,7 +141,7 @@ printscol(DISPLAY *dp) /* * print name in current style */ -static int +int printname(const char *name) { if (f_octal || f_octal_escape)