shopt-option

autocd shell option

In interactive Bash, a command word that is a directory name can act like cd when no ordinary command is resolved. This changes the current directory; use explicit cd in scripts and avoid names that collide with commands. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Use interactive Bash with default key bindings; expected visible result: project.

Formal Syntax & Structure

bash syntaxbash
shopt -s autocd; shopt -u autocd

Return Value

exit status

Returns zero on success and nonzero on failure; option queries return zero when enabled.

Working Example

Example Snippetbash
# In fresh interactive Bash in an empty private directory:mkdir projectshopt -s autocdprojectprintf '%s\n' "${PWD##*/}"
Bash Reference