From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 19 06:00:20 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E3A916A417 for ; Sun, 19 Aug 2007 06:00:20 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 20EB613C467 for ; Sun, 19 Aug 2007 06:00:20 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l7J60KA8077588 for ; Sun, 19 Aug 2007 06:00:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7J60J2j077587; Sun, 19 Aug 2007 06:00:19 GMT (envelope-from gnats) Date: Sun, 19 Aug 2007 06:00:19 GMT Message-Id: <200708190600.l7J60J2j077587@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ighighi Cc: Subject: Re: bin/112920: [PATCH]: wrong realpath(1) behaviour X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ighighi List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2007 06:00:20 -0000 The following reply was made to PR bin/112920; it has been noted by GNATS. From: Ighighi To: bug-followup@freebsd.org Cc: Subject: Re: bin/112920: [PATCH]: wrong realpath(1) behaviour Date: Sun, 19 Aug 2007 01:58:38 -0400 This is a multi-part message in MIME format. --------------020007070406020003010508 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The patch that should have been attached in the previous post. --------------020007070406020003010508 Content-Type: text/x-patch; name="realpath.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="realpath.patch" # # (c) 2007 by Ighighi # # This patch adds support for multiple arguments to realpath(1) and # makes it use getopt(3). It also corrects the following problem: # http://www.freebsd.org/cgi/query-pr.cgi?pr=112920 # --- src/bin/realpath/realpath.c.orig Tue Apr 6 16:06:50 2004 +++ src/bin/realpath/realpath.c Thu May 24 18:28:49 2007 @@ -44,13 +44,26 @@ { char buf[PATH_MAX]; char *p; + int ch; - if (argc == 2) { - if ((p = realpath(argv[1], buf)) == NULL) - err(1, "%s", buf); - } else + while ((ch = getopt(argc, argv, "")) != -1) + switch(ch) { + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (argc < 1) usage(); - (void)printf("%s\n", p); + + do { + if ((p = realpath(*argv, buf)) == NULL) + err(1, "%s", *argv); + else + (void)printf("%s\n", p); + } while (*++argv != NULL); exit(0); } @@ -58,6 +71,6 @@ usage(void) { - (void)fprintf(stderr, "usage: realpath path\n"); + (void)fprintf(stderr, "usage: realpath path [...]\n"); exit(1); } --- src/bin/realpath/realpath.1.orig Sun Jan 16 12:41:58 2005 +++ src/bin/realpath/realpath.1 Thu May 24 03:20:11 2007 @@ -42,6 +42,7 @@ .Sh SYNOPSIS .Nm .Ar path +.Op Ar ... .Sh DESCRIPTION The .Nm --------------020007070406020003010508--