Make `realpath'' behave like
`realpath .''.
This commit is contained in:
parent
35d200101a
commit
7a416f3e7d
@ -33,7 +33,7 @@
|
||||
.\" From: src/bin/pwd/pwd.1,v 1.11 2000/11/20 11:39:39 ru Exp
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 24, 2000
|
||||
.Dd June 21, 2011
|
||||
.Dt REALPATH 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -42,8 +42,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl q
|
||||
.Ar path
|
||||
.Op Ar ...
|
||||
.Op Ar path ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -57,6 +56,11 @@ and
|
||||
.Pa /../
|
||||
in
|
||||
.Ar path .
|
||||
If
|
||||
.Ar path
|
||||
is absent, the current working directory
|
||||
.Pq Sq Pa .\&
|
||||
is assumed.
|
||||
.Pp
|
||||
If
|
||||
.Fl q
|
||||
|
@ -44,7 +44,8 @@ main(int argc, char *argv[])
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char *p;
|
||||
int ch, i, qflag, rval;
|
||||
const char *path;
|
||||
int ch, qflag, rval;
|
||||
|
||||
qflag = 0;
|
||||
while ((ch = getopt(argc, argv, "q")) != -1) {
|
||||
@ -59,17 +60,16 @@ main(int argc, char *argv[])
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc < 1)
|
||||
usage();
|
||||
path = *argv != NULL ? *argv++ : ".";
|
||||
rval = 0;
|
||||
for (i = 0; i < argc; i++) {
|
||||
if ((p = realpath(argv[i], buf)) == NULL) {
|
||||
do {
|
||||
if ((p = realpath(path, buf)) == NULL) {
|
||||
if (!qflag)
|
||||
warn("%s", argv[i]);
|
||||
warn("%s", path);
|
||||
rval = 1;
|
||||
} else
|
||||
(void)printf("%s\n", p);
|
||||
}
|
||||
} while ((path = *argv++) != NULL);
|
||||
exit(rval);
|
||||
}
|
||||
|
||||
@ -77,6 +77,6 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: realpath [-q] path [...]\n");
|
||||
(void)fprintf(stderr, "usage: realpath [-q] [path ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user