Bash Reference Manual
In a non-interactive shell, or an interactive shell in which the
interactive_comments option to the
builtin is enabled (see section 4.2 Bash Builtin Commands),
a word beginning with `#'
causes that word and all remaining characters on that line to
be ignored. An interactive shell without the
option enabled does not allow comments. The
option is on by default in interactive shells.
See section 6.3 Interactive Shells, for a description of what makes
a shell interactive.