tcsh:ls vs pwd vs cd

时间:2016-09-06 07:21:41

标签: linux symlink ls tcsh

我想在tcsh中创建文件结构的映射。 给定结构1,仅使用物理文件夹,例如:

<data type>.MaxValue

结构2只包含物理文件夹,但是最后一个目录,这是结构1的“mary”的符号链接:

/map/peter/paul/mary

如果我更改为/map/horse/dog/mouse ; mouse -> ../../peter/paul/mary ,如果我制作/map/horse/dog/mouse,则会告诉我

pwd

如果我在/map/horse/dog/mouse ,如果我在/map/horse/dog/mouse,我就在<{p>

cd ..

但如果我在/map/horse/dog 并且如果我/map/horse/dog/mouse,则会告诉我ls ..,而不是mary

我了解mouse会记住以前的工作目录cddog更改回cd ..,而dog会解析符号链接并显示ls .. 1}},但我希望mary向我展示ls ..

以同样的方式,我希望mouse向我展示ls ../..

我发现的所有用例都是关于解析符号链接和显示物理路径。但就我而言,对于“ls”,我只需要一种方法来接收未解决的路径。

所以,在“/ horse / dog / mouse”中制作“ls ..”,我希望看到“鼠标”,而不是“mary”。

将“鼠标”设置为物理文件夹并将符号链接“鼠标”为“鼠标”不是一个选项,因为“mary”存在于“鼠标”之前。

感谢您解决我的问题的任何帮助/想法。

1 个答案:

答案 0 :(得分:0)

是的,默认行为是不一致的。您可以使用symlinks设置控制其中一些内容;例如:

set symlinks=chase

tcsh转到&#34;真实&#34;使用cd之后的目录,这是你想要的(我认为)。

还有expandignore设置。引用tcsh(1)

   symlinks (+)
           Can be set to several different values to control symbolic link
           (`symlink') resolution:

           If  set to `chase', whenever the current directory changes to a
           directory containing a symbolic link, it  is  expanded  to  the
           real name of the directory to which the link points.  This does
           not work for the user's home directory; this is a bug.

           If set to `ignore', the shell  tries  to  construct  a  current
           directory relative to the current directory before the link was
           crossed.  This means that cding through  a  symbolic  link  and
           then  `cd  ..'ing  returns one to the original directory.  This
           affects only builtin commands and filename completion.

           If set to `expand', the shell tries to fix  symbolic  links  by
           actually  expanding arguments which look like path names.  This
           affects any command, not just  builtins.   Unfortunately,  this
           does  not  work  for hard-to-recognize filenames, such as those
           embedded in command options.  Expansion  may  be  prevented  by
           quoting.  While this setting is usually the most convenient, it
           is sometimes misleading and sometimes confusing when  it  fails
           to  recognize  an argument which should be expanded.  A compro‐
           mise is to use `ignore' and use the editor  command  normalize-
           path (bound by default to ^X-n) when necessary.