From owner-freebsd-bugs Wed Dec 26 3:50:14 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A50B337B41F for ; Wed, 26 Dec 2001 03:50:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBQBo2X46712; Wed, 26 Dec 2001 03:50:02 -0800 (PST) (envelope-from gnats) Date: Wed, 26 Dec 2001 03:50:02 -0800 (PST) Message-Id: <200112261150.fBQBo2X46712@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: mikem Subject: Re: bin/33187: [PATCH] /bin/ls -dF adds trailing slash regardless of whether there is already one there Reply-To: mikem Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/33187; it has been noted by GNATS. From: mikem To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: bin/33187: [PATCH] /bin/ls -dF adds trailing slash regardless of whether there is already one there Date: Wed, 26 Dec 2001 04:00:44 -0800 ok, let's try this one more time... --- /usr/src/bin/ls/ls.c Tue Nov 27 06:30:05 2001 +++ ls.c Wed Dec 26 03:35:50 2001 @@ -132,7 +132,7 @@ { static char dot[] = ".", *dotav[] = { dot, NULL }; struct winsize win; - int ch, fts_options, notused; + int ch, fts_options, notused, index, len; char *p; #ifdef COLORLS @@ -382,6 +382,19 @@ printfcn = printlong; else printfcn = printcol; + + /* + * Remove trailing '/' if -d and -F are specified + * so we don't get into the situation where: + * % ls -dF /usr/ + * outputs: /usr// + */ + if (f_listdir && f_type) + for(index=0; index < argc ; index++) { + len = strlen(argv[index]); + if (argv[index][len - 1] == '/') + argv[index][len - 1] = '\0'; + } if (argc) traverse(argc, argv, fts_options); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message