"cd -L /usr/adm ; lc .." == "lc /var" ??

"cd -L /usr/adm ; lc .." == "lc /var" ??

Post by Jaume Solà Bayarr » Thu, 14 May 1998 04:00:00



I know how to use symbolic links, and the "-L" and "-P" options of the
"cd" and "pwd" commands.

If I do : "cd -L /usr/adm ; lc ..", I expect to see the same result than
"lc /usr", but what I get is "lc /var".

Ive tried with "sh -L", and I get the same result.If seems that the
"-L" option only affects
the "cd" and "pwd" commands, but "lc" or any other command always
follows the phisical path.

Is there any way for forcing all commands to follow the logical path ?

Thanks in advance.

 
 
 

"cd -L /usr/adm ; lc .." == "lc /var" ??

Post by Bela Lubki » Sat, 16 May 1998 04:00:00



> I know how to use symbolic links, and the "-L" and "-P" options of the
> "cd" and "pwd" commands.

> If I do : "cd -L /usr/adm ; lc ..", I expect to see the same result than
> "lc /usr", but what I get is "lc /var".

> I've tried with "sh -L", and I get the same result.If seems that the
> "-L" option only affects
> the "cd" and "pwd" commands, but "lc" or any other command always
> follows the phisical path.

> Is there any way for forcing all commands to follow the logical path ?

No.

The "logical path" exists only inside the shell's mind.  When you run
`lc ..`, you are running an external program, and passing to it the name
of an actual file in the current directory.  All directories have a file
(actually a directory) in them, named "..", which is their parent.
There is only one instance of a particular directory, and its ".." is
always the same, no matter how you cd'd to it.

You might propose that the shell should modify the `..' you've typed,
changing it to the "logical" parent of the current directory.  You would
type `lc ..`, but the shell would actually run `lc /usr`.  The problem
with that is, the shell has to assume that ".." always refers to a
filename.  But you might be doing something completely different:

  echo ..
  banner ..

The shell would also have to do complex parsing of the command line.
For example,

  lc /tmp ..
  dd if=../foo of=../bar/baz

Even if it did all that, there's no way it could affect references to
".." from inside a program:

  Enter the name of the file to print: ../myfile

Quote:>Bela<