Date: Wed, 9 Jan 2002 16:19:06 +0200 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Sheldon Hearn <sheldonh@starjuice.net> Cc: audit@FreeBSD.ORG, bug-followup@FreeBSD.ORG Subject: Re: bin/33187: ls -dF and trailing slashes Message-ID: <20020109161906.N41379@sunbay.com> In-Reply-To: <57311.1010584273@axl.seasidesoftware.co.za> References: <57311.1010584273@axl.seasidesoftware.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 09, 2002 at 03:51:13PM +0200, Sheldon Hearn wrote: > > 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. > It also doesn't work for ``ls -dF /usr//'' and breaks ``ls -dF /''. > 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); Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age 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?20020109161906.N41379>