= Popd built-in
:encoding: UTF-8
:lang: en
//:title: Yash manual - Popd built-in

The dfn:[popd built-in] pops a directory from the directory stack.

[[syntax]]
== Syntax

- +popd [{{index}}]+

[[description]]
== Description

The popd built-in removes the last entry from the link:_dirs.html[directory
stack], returning to the previous working directory.
If {{index}} is given, the entry specified by {{index}} is removed instead of
the last one. 

[[operands]]
== Operands

{{index}}::
The index of a directory stack entry you want to remove.
+
If omitted, `+0` (the last entry) is assumed.

[[exitstatus]]
== Exit status

In addition to the link:_cd.html#exitstatus[exit status of the cd built-in],
the popd built-in returns the following exit status:

* If the link:params.html#sv-dirstack[+DIRSTACK+ variable] is read-only or
  empty, the exit status is 4.
* If {{index}} is out of range, the exit status is 4.

[[notes]]
== Notes

It is an error to use this built-in when there is only one directory stack
entry.

The popd built-in is an link:builtin.html#types[elective built-in].
It cannot be used in the link:posix.html[POSIXly-correct mode]
because POSIX does not define its behavior.

// vim: set filetype=asciidoc textwidth=78 expandtab:
