Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Change interactive command into a comment



The answer to that (assuming extended_glob) is way at the bottom of the
Expansion docs:
http://zsh.sourceforge.net/Doc/Release/Expansion.html#Filename-Generation

To quote directly:

x#
(Requires EXTENDED_GLOB to be set.) Matches zero or more occurrences of the
pattern x. This operator has high precedence; ‘12#’ is equivalent to
‘1(2#)’, rather than ‘(12)#’. It is an error for an unquoted ‘#’ to follow
something which cannot be repeated; this includes an empty string, a
pattern already followed by ‘##’, or parentheses when part of a KSH_GLOB
pattern (for example, ‘!(foo)#’ is invalid and must be replaced by
‘*(!(foo))’).

x##
(Requires EXTENDED_GLOB to be set.) Matches one or more occurrences of the
pattern x. This operator has high precedence; ‘12##’ is equivalent to
‘1(2##)’, rather than ‘(12)##’. No more than two active ‘#’ characters may
appear together. (Note the potential clash with glob qualifiers in the form
‘1(2##)’ which should therefore be avoided.)

*\Ben Klein*
About: https://unhexium.net/about/
Other places online: https://unhexium.net/ll/
Contact me securely: https://keybase.io/robobenklein


On Wed, Nov 13, 2019 at 7:25 PM Perry Smith <pedz@xxxxxxxxxxxxxxxx> wrote:

> With bash, I got into the following habit.  If I started typing a long
> command and then decided I didn’t want to execute it right now for some
> reason, I would hit control-A to get back to the start of the line and then
> add a # in front and hit return.
>
> This would put the command into history and so later I could recall it,
> remove the #, and execute the command.
>
> With zsh, when I add the # to the front and hit return I get:
>
>     zsh: bad pattern: #
>
> I found INTERACTIVE_COMMENTS but now I’m curious, what is zsh trying to do
> with a line starting with # ?  e.g. # echo dog
>
>


Messages sorted by: Reverse Date, Date, Thread, Author