在bash 4.4.12,help cd说:
Run Code Online (Sandbox Code Playgroud)Options: -L force symbolic links to be followed: resolve symbolic links in DIR after processing instances of `..' -P use the physical directory structure without following symbolic links: resolve symbolic links in DIR before processing instances of `..' -e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status -@ on systems that support it, present a file with extended attributes as a directory containing the file attributes
我很难理解这些词,而且我的 google-fu 无法提出任何内容。
cd -P会被首选的例子是什么cd?cd -L标准不同cd?-@?该猛砸手册给出了更详细一点。
cd -P 确保你最终得到一个“真实”的路径:
$ cd /tmp
$ mkdir -p a/b
$ ln -s a/b b
$ cd b
$ pwd
/tmp/b
$ cd -P ../b
$ pwd
/tmp/a/b
Run Code Online (Sandbox Code Playgroud)
Using-P表示来自bto的符号链接a/b被取消引用。与..is的交互..通常是通过删除前一个路径组件来处理的,如果有的话;不是通过检查磁盘上的路径。如果您使用大量符号链接,这最终会变得非常混乱。
cd -L相当于默认值cd。
无法确定当前工作目录是否已被删除:
$ cd /tmp
$ mkdir -p c/d
$ cd c/d
$ rmdir ../d ../../c
$ cd ..; echo $?
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
0
Run Code Online (Sandbox Code Playgroud)
v.
$ cd -Pe ..; echo $?
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
1
Run Code Online (Sandbox Code Playgroud)这我不知道(我能想象它会是什么样子,但击只是说“ cd:-@:无效选项”;我得到的印象,这是目前仅在Solaris上可用的,它需要O_XATTR)。
| 归档时间: |
|
| 查看次数: |
3035 次 |
| 最近记录: |