Many bash scripts invoke the #
character to indicate a comment. Catalina migrated to zsh. The command:
# Comments should elicit no response
returns
zsh: command not found: #
I find useful command examples on the web: it is helpful to annotate commands with said #weblink so that it is captured in the history.
I did find this post: https://stackoverflow.com/a/11873793/4953146
- Is there a reason for the
#
not to be recognized as the comment character in zsh? - How can the terminal be configured to recognize the character as a comment?
Question 1 sets the context for deciding on a method to address question 2. It would nice to be able to configure the character once and all future instances of zsh would follow. If there is / was a good reason why the feature was disabled, I would like to understand any reasons.
Understanding the 'why' is important to determine the 'how'. There seems to be many ways to restore #
commenting in zsh. One durable solution is to add to the configuration file: sudo vi /etc/zshrc
:
setopt interactivecomments
Other methods (not durable) include invoking ksh or sh.
Many thanks to user3439894 & Allan for supporting / advancing the question.
#
is recognized as the comment character in scripts by zsh#
as the comment character, but to understand the context as to why it is disabled and any possible unintended consequences of enabling#
. This context would serve to better choose a method of enablement.#
within a script is interpreted as comment (correctly) but issued by itself on the command line it throws that error. I'm endeavoring to find out why myself! Good question +1