From owner-freebsd-audit Wed Jan 9 6:19:46 2002 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 7E84B37B404; Wed, 9 Jan 2002 06:19:38 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g09EJ6H80172; Wed, 9 Jan 2002 16:19:06 +0200 (EET) (envelope-from ru) Date: Wed, 9 Jan 2002 16:19:06 +0200 From: Ruslan Ermilov To: Sheldon Hearn Cc: audit@FreeBSD.ORG, bug-followup@FreeBSD.ORG Subject: Re: bin/33187: ls -dF and trailing slashes Message-ID: <20020109161906.N41379@sunbay.com> References: <57311.1010584273@axl.seasidesoftware.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57311.1010584273@axl.seasidesoftware.co.za> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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