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-fu는 아무것도 가져올 수 없습니다.

  1. cd -P보다 선호되는 경우의 예는 무엇입니까 cd?
  2. cd -L표준과 어떻게 다른가요 cd?
  3. 작업 디렉터리를 성공적으로 결정하지 못하는 것이 어떻게 가능합니까?
  4. 을 사용한 예는 무엇입니까 -@?

답변1

그만큼배쉬 매뉴얼좀 더 자세히 알려줍니다.

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

관련 정보