From: Hauke Petersen <hkptrsn@gmail.com>
To: zsh-workers@zsh.org
Subject: Inconsistent history expansion of characters adjacent to histchar
Date: Mon, 7 Oct 2013 17:55:51 +0200 [thread overview]
Message-ID: <CANWLQWuM4CBXOmLkVpFN4PO3cLj72qQYbbbGZKxoAqdBwz05kw@mail.gmail.com> (raw)
zshexpn(1), heavily elided:
HISTORY EXPANSION
Following [the exclamation mark] is an optional event designator and then
an optional word designator; _if neither of these designators is present,
no history expansion occurs._
AFAICT, that's only partially true.
% print !
!
% print !; print foo
print print !; print foo
print !
foo
It does not immediately make sense to me why a single `!' would be
interpreted as a double `!!' before a `;' and tried, unsuccessfully,
to find an explanation.
Event Designators
! Start a history expansion, except when followed by a blank, new-line,
`=' or `('. If followed immediately by a word designator, this forms a
history reference with no event designator.
[!!, !n, !-n, !str, !?str[?], !#, !{...}]
There is also this:
a history reference with no event designator refers to the same event as
any preceding history reference on that command line; if it is the only
history reference in a command, it refers to the previous command
but that only applies to references with a word designator, which
there isn't in `!;'. Nor does it satisfy the definition of any of the
event designators except `!str', but then it would a) eat the `;' as
being part of the reference, and b) fail with `event not found: ;' if
there is no previous command starting with ';'. Like otherwise
similar `&':
% print !& print foo
zsh: event not found: &
Instead, as above, it expands like `!!;' which every once a while
makes my heart skip two beats when I realize what could have happened
in lines like the following with a previous command other than `:'.
% :
% ./foo & touch foo.$!; wait $!; rm foo.$!; printf \\a
./foo & touch foo.$:; wait $:; rm foo.$:; printf \\a
[1] 3828
wait: job not found: $:
I know expansion is always potentially destructive and, yes,
HIST_VERIFY could prevent the worst of it, but I do not think the
current behavior makes sense in the first place. I'd expect and
prefer `!;' not to be interpreted as a history reference, but seeing
the behavior of `!&', I think it should at least behave consistently.
(Sorry about the verbosity.)
next reply other threads:[~2013-10-07 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 15:55 Hauke Petersen [this message]
2013-10-08 2:56 ` Bart Schaefer
2013-10-08 14:31 ` Bart Schaefer
2013-10-08 14:44 ` Peter Stephenson
2013-10-08 15:43 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANWLQWuM4CBXOmLkVpFN4PO3cLj72qQYbbbGZKxoAqdBwz05kw@mail.gmail.com \
--to=hkptrsn@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).