Date: Wed, 09 Jan 2002 15:51:13 +0200 From: Sheldon Hearn <sheldonh@starjuice.net> To: audit@FreeBSD.org Subject: bin/33187: ls -dF and trailing slashes Message-ID: <57311.1010584273@axl.seasidesoftware.co.za>
next in thread | raw e-mail | index | archive | help
Hi folks,
What do you think of the following patch, taken from PR bin/33187?
It prevents
ls -dF /usr/
from producing
/usr//
which may confuse other programs for which this output is used as input.
Ciao
Sheldon.
Index: ls.c
===================================================================
RCS file: /home/ncvs/src/bin/ls/ls.c,v
retrieving revision 1.51
diff -u -d -r1.51 ls.c
--- ls.c 29 Dec 2001 00:22:29 -0000 1.51
+++ ls.c 9 Jan 2002 13:34:48 -0000
@@ -135,7 +135,7 @@
{
static char dot[] = ".", *dotav[] = {dot, NULL};
struct winsize win;
- int ch, fts_options, notused;
+ int ch, fts_options, i, len, notused;
char *p;
#ifdef COLORLS
char termcapbuf[1024]; /* termcap definition buffer */
@@ -392,6 +392,17 @@
printfcn = printlong;
else
printfcn = printcol;
+
+ /*
+ * If -d and -F options, strip trailing slashes from arguments
+ * to avoid duplicated terminating slashes in output.
+ */
+ if (f_listdir && f_type)
+ for(i=0; i < argc ; i++) {
+ len = strlen(argv[i]);
+ if (argv[i][len - 1] == '/')
+ argv[i][len - 1] = '\0';
+ }
if (argc)
traverse(argc, argv, fts_options);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?57311.1010584273>
