From owner-freebsd-audit Wed Jan 9 5:49: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id 215F237B417 for ; Wed, 9 Jan 2002 05:49:00 -0800 (PST) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 16OJ8L-000EuO-00 for audit@FreeBSD.org; Wed, 09 Jan 2002 15:51:13 +0200 From: Sheldon Hearn To: audit@FreeBSD.org Subject: bin/33187: ls -dF and trailing slashes Date: Wed, 09 Jan 2002 15:51:13 +0200 Message-ID: <57311.1010584273@axl.seasidesoftware.co.za> 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 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