I hoped that softlinks are "transparent" to the user. I have mapped
several folders into ONE root folder.
In the bash I can switch between these folders very easily (cd ../a, cd
../b)
--> In ruby I cannot switch between these folders because the resulting
path is the target of the symlink. This is not very nice.
Imho "chdir(mydir)" should change into the softlink dir and
"chdir(File.readlink(mydir))" should change into the target dir.
Maybe anyone else knows a trick or has an idea? Or is that a feature
request?
This excercise shows that there is no such notion as a symlinked working
directory, it's just bash being clever. I.e. the system calls always resolve
the soft links (or ELOOP), but bash manages the state of the soft links.
If you look into the documentation of ls and cd you see the options -L/-P
(as mentioned earlier).
If you want another excercise (go back to the original directory), try:
#> mkdir temp
#> ln -sf $PWD/foo temp/bar
#> cd temp/bar
#> ls ..
You might be surprised that the directory being listed is actually the
initial $PWD, not $PWD/temp. This is because ls usually is not a bash
built-in, but a real command.
The result: if you want symlink magic, you have to do it like bash; the hard
way : ).
Hope this clears things up!
Thanks for the explanation, I understand the problem now.
However, is there ANY (hard) way to get the current symlinked directory
and not the symlink target in a ruby script (Dir.pwd returns "only" the
target)?
Thanks for the explanation, I understand the problem now.
I am not sure: why do you ask then?
However, is there ANY (hard) way to get the current symlinked directory
and not the symlink target in a ruby script (Dir.pwd returns "only" the
target)?
As JJ said: you need to do it like bash and do it manually (i.e. keep
track of your idea of the current working directory path).
Kind regards
robert
···
On Mon, Sep 19, 2011 at 4:55 PM, Alexander Schaal <aschaal@lear.com> wrote: