readlink: simplify -f

Use output from realpath(3) directly. This makes usage
with . more consistent with other implementations.
This commit is contained in:
Eivind Uggedal 2015-06-04 20:36:40 +00:00 committed by sin
parent 7e035a9a2e
commit 93043beec9
1 changed files with 2 additions and 5 deletions

View File

@ -76,11 +76,8 @@ mdone:
eprintf("realpath %s:", argv[0]);
break;
case 'f':
p = dirname(estrdup(argv[0]));
if (!realpath(p, b))
eprintf("realpath %s:", p);
estrlcat(b, "/", sizeof(arg));
estrlcat(b, basename(estrdup(argv[0])), sizeof(arg));
if (!realpath(argv[0], b))
eprintf("realpath %s:", argv[0]);
break;
default:
if ((n = readlink(argv[0], b, PATH_MAX - 1)) < 0)