The POSIX utility syntax guidelines (specifically #13) specify that for utilities that expect a file name to read from,
- means standard input, and for utilities that expect a file name to write to,
- means standard output. For example,
cat somefile - copies the content of
somefile to its standard output, followed by what it reads on its standard input.
This guideline doesn't apply to the
cd command since it doesn't read or write to a file.
cd does something different: the argument
- means “the previous directory”. The command
cd - is equivalent to
cd "$OLDPWD" && pwd. This behavior is specific to the
cd command, and to directly inspired commands such as
- is an operand, not an option. Only arguments that begin with
- and are not just
-- are options. The main implication of being an operand is that
-- doesn't affect its special meaning. For example,
cd -- -P changes to a subdirectory called
cd -- - is the same as
cd -, it doesn't change to a directory called
cat -- - doesn't read from a file called
- but from standard input.