helpThe GNU Bourne-Again SHell - Support: sr #109360, pushd into current directory cause...


sr #109360: pushd into current directory cause popd to fail

Submitted by:  None
Submitted on:  Mon 24 Jul 2017 06:15:18 AM UTC  
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: Works For Me
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 03 Aug 2017 02:09:24 AM UTC, comment #1:

I don't get these results with bash-4.3 or bash-4.4.

Chet Ramey <chet>
Project Administrator
Mon 24 Jul 2017 06:15:18 AM UTC, original submission:

If you pushd into the current directory, the command will exit successfully but without putting the current directory into the stack, causing the subsequent popd to fail either because a stack mismatch, or because the stack is empty.

Test case 1:

Open new terminal.
Run pushd ~/
Run popd
failed with popd: directory stack empty
Test case 2:

Open new terminal.
Run cd /
Run pushd ~/
Run pushd ~/
Run popd, this should cd to ~/ and pop the stack to /, but it cd to / instead and stack is now empty.
Run popd again, stack is empty so command failed with popd: directory stack empty

Tested on bash 4.3.48(1) on ubuntu 16.04 x86_64



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by chet (Posted a comment)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 03 Aug 2017 02:09:24 AM UTCchetStatusNone=>Works For Me

    Back to the top

    Powered by Savane 3.1-cleanup1