Date: Sun, 19 Aug 2007 06:00:19 GMT From: Ighighi <ighighi@gmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/112920: [PATCH]: wrong realpath(1) behaviour Message-ID: <200708190600.l7J60J2j077587@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/112920; it has been noted by GNATS. From: Ighighi <ighighi@gmail.com> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708190600.l7J60J2j077587>