2016-09-06 4 views
0

Я хочу сделать сопоставление файловых структур в tcsh. Учитывая это строение 1, только с физическими папками, говорят:tcsh: ls vs pwd vs cd

/map/peter/paul/mary 

Структура 2 содержит только физические папки, но последний каталог, это символическая ссылка на «мэри» из состава 1:

/map/horse/dog/mouse ; mouse -> ../../peter/paul/mary 

Если я изменяю /map/horse/dog/mouse и если я сделаю pwd, он говорит мне

/map/horse/dog/mouse 

Если я в /map/horse/dog/mouse и если Я делаю cd .., я в

/map/horse/dog 

, но если я в /map/horse/dog/mouse и если я делаю ls .., он говорит мне mary, но не mouse.

Я понимаю, что cd помнит предыдущий рабочий каталог dog и cd .. изменения обратно в dog, в то время как ls .. решает симлинк и показывает мне mary, но я хочу ls .., чтобы показать мне mouse.

Точно так же я хочу ls ../.., чтобы показать мне dog.

Все использованные случаи, которые я нашел, касаются разрешения символических ссылок и отображения физического пути. Но в моем случае, для «ls», мне нужен способ получить неразрешенный путь.

Итак, находясь в «/ horse/dog/mouse» и делая «ls ..», я хочу видеть «мышь», но не «mary».

Создание «мыши» физической папки и «mary» символической ссылки на «мышь» не является опцией, потому что «mary» существует до «мыши».

Любая помощь/идеи для решения моей проблемы приветствуется.

+0

Этот вопрос кажется более подходящим для [unix.se]. –

ответ

0

Да, поведение по умолчанию является непоследовательным. Вы можете управлять некоторыми из них с помощью настройки symlinks; например:

set symlinks=chase 

Сделает tcsh идти к «реальному» каталогу после использования cd, который является то, что вы хотите (я думаю).

Есть также настройки expand и ignore. Цитирование 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. 
Смежные вопросы