Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Absolute path of a path
- X-seq: zsh-workers 28381
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Absolute path of a path
- Date: Thu, 28 Oct 2010 08:44:33 -0400 (EDT)
- In-reply-to: <20101028105250.GB7283@xxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AANLkTikZN2Lk3zf2fWqD917TA-Wa5jCBQSZ-7VNWVOCj@xxxxxxxxxxxxxx> <AANLkTi=j_OtAziY1X=1qj=zk3P7=U6my1sd=bVshp69u@xxxxxxxxxxxxxx> <20101027164454.GA19471@xxxxxxxxxxxxxxxxxxx> <AANLkTinLOXXBT=Wsu+gKLSEMgGGPg33c+_93CyS6xLsG@xxxxxxxxxxxxxx> <20101028104451.GB19471@xxxxxxxxxxxxxxxxxxx> <20101028105250.GB7283@xxxxxxxxxxxxxxxxxxx>
[moving to -workers]
On 2010-10-28 12:44:51 +0200, Vincent Lefevre wrote:
FYI:
ypig:~> realpath symlink/../vlefevre/symlink
/home/vlefevre
ypig:~> echo symlink/../vlefevre/symlink(:A)
/home/vlefevre/vlefevre/symlink
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.
$ echo $ZSH_VERSION $ZSH_PATCHLEVEL
4.3.10-dev-1 1.5015
$ pwd
/home/bhaskell/tmp
$ readlink symlink
.
$ echo symlink/../tmp/symlink(:A)
/home/bhaskell/tmp/tmp/symlink
## /home/bhaskell/tmp/tmp doesn't exist
$ A () { reply=("$(perl -MCwd=realpath -we 'print realpath shift' $REPLY)") }
$ echo symlink/../tmp/symlink(+A)
/home/bhaskell/tmp
$ gcc -Wall -o realpath-test{,.c}
$ ./realpath-test symlink/../tmp/symlink
/home/bhaskell/tmp
--
Best,
Ben
#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