FreeTibet
@FreeTibet
dharma supplier

Бесполезный вопрос nix shell

На многих системах, до которых дотянулись руки (linux, opensolaris) замечал такую штуку: если набрать 'cd //' то эти '//' попадают в промпт. Но только если две.
[root@ns4m40:/] cd /
[root@ns4m40:/] cd //
[root@ns4m40://] cd ///
[root@ns4m40:/] cd ////
[root@ns4m40:/] cd /////
[root@ns4m40:/]

почему так?
  • Вопрос задан
  • 2352 просмотра
Решения вопроса 1
Evengard
@Evengard
tiswww.case.edu/php/chet/bash/FAQ

E10) Why does 'cd //' leave $PWD as '//'?

POSIX.2, in its description of 'cd', says that three or more leading slashes may be replaced with a single slash when canonicalizing the current working directory.

This is, I presume, for historical compatibility. Certain versions of Unix, and early network file systems, used paths of the form //hostname/path to access 'path' on server 'hostname'.
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
m08pvv
@m08pvv
Вот ещё на эту тему, но не про 'cd'

>>>>It's explained in POSIX, «4.11 Pathname resolution».
>>
>>>>«A pathname consisting of a single slash shall resolve to the root
>>>>directory of the process. A null pathname shall not be successfully
>>>>resolved. A pathname that begins with two successive slashes may be
>>>>interpreted in an implementation-defined manner, although more than two
>>>>leading slashes shall be treated as a single slash.»
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы