bash cd のオプションの例: cd -Pe@ $directory

bash cd のオプションの例: cd -Pe@ $directory

ではbash 4.4.12、次のようにhelp cd述べています。

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 で検索しても何も出てきません。

  1. cd -Pが よりも好まれる場合の例は何ですかcd?
  2. cd -L標準とどう違うのですかcd?
  3. 作業ディレクトリを正常に特定できないのはなぜでしょうか?
  4. の使用例は何ですか-@?

答え1

Bash マニュアルもう少し詳しく説明します。

  1. 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
    

    を使用すると、から-Pへのシンボリックリンクが逆参照されます。とのやり取りは、通常、ディスク上のパスをチェックするのではなく、以前のパス コンポーネントがある場合はそれを削除することによって処理されます。シンボリックリンクを多数使用すると、非常に混乱する可能性があります。ba/b....

  2. cd -Lデフォルトと同等ですcd

  3. 現在の作業ディレクトリは削除されている場合は判別できません。

    $ 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
    

    v.

    $ cd -Pe ..; echo $?
    cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
    1
    
  4. これについてはよくわかりません (どのように表示されるかは想像できますが、Bash では単に「cd: -@: 無効なオプション」と表示されます。これは現在 Solaris でのみ使用可能で、 が必要であるという印象を受けますO_XATTR)。

関連情報