Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Absolute path of a path

[moving to -workers]

On 2010-10-28 12:44:51 +0200, Vincent Lefevre wrote:

ypig:~> realpath symlink/../vlefevre/symlink

ypig:~> echo symlink/../vlefevre/symlink(:A)

where symlink is a symbolic link to ".".

I think that this is even a bug in zsh, as

ypig:~> echo symlink/../vlefevre/symlink2(:A)
zsh: no match

So, it seems that resolution as been done correctly (it is detected that symlink/../vlefevre/symlink exists but not symlink/../vlefevre/symlink2), however the output for the former one /home/vlefevre/vlefevre/symlink doesn't exist (there's no vlefevre file or directory in /home/vlefevre).

FWIW, my Perl-based workaround does the right thing, as does the attached simple C program. Seems like a bug.

4.3.10-dev-1 1.5015
$ pwd
$ readlink symlink

$ echo symlink/../tmp/symlink(:A)
## /home/bhaskell/tmp/tmp doesn't exist

$ A () { reply=("$(perl -MCwd=realpath -we 'print realpath shift' $REPLY)") }
$ echo symlink/../tmp/symlink(+A)

$ gcc -Wall -o realpath-test{,.c}
$ ./realpath-test symlink/../tmp/symlink

#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv) {
	char resolved[PATH_MAX];
	if (argc < 2) {
		fprintf(stderr, "Usage: %s path\n", argv[0]);
		return 1;
	realpath(argv[1], resolved);
	printf("%s\n", resolved);
	return 0;

Messages sorted by: Reverse Date, Date, Thread, Author