Pushdは常に現在のディレクトリをプッシュしますか?

Pushdは常に現在のディレクトリをプッシュしますか?
$ pwd
/tmp/d1
$ dirs
/tmp/d1
$ pushd ../d2
/tmp/d2 /tmp/d1
$ popd
/tmp/d1
$ pwd
/tmp/d1

pushd現在のディレクトリを?/tmp/d1に入れたにもかかわらず、常にスタックにプッシュしているようです。pushd ../d2走る

気づく:http://linux.101hacks.com/cd-command/dirs-pushd-popd/

dir コマンドの最初のディレクトリ出力は、常にスタックの内容ではなく、現在のディレクトリです。

ベストアンサー1

いいえ、pushd現在のディレクトリが常にプッシュされるわけではありません。bash'ページからman

   pushd [-n] [+n] [-n]
   pushd [-n] [dir]
          Adds  a directory to the top of the directory stack, or rotates
          the stack, making the new top of the stack the current  working
          directory.   With  no arguments, exchanges the top two directo‐
          ries and returns 0, unless the directory stack is empty.
          .
          .
          dir    Adds  dir  to  the directory stack at the top, making it
                 the new current working directory.

ディレクトリを含むフォームは、pushd [dir]ディレクトリが明示的にパラメータとして使用されない限り、現在のディレクトリを使用しません。行為pushd somedir

おすすめ記事