From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3838 invoked by alias); 7 Oct 2013 15:56:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31796 Received: (qmail 27603 invoked from network); 7 Oct 2013 15:56:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=7wLIPyAXL3va+r2hyiodgGxtzruri55yZil6HccYbyw=; b=sxTKI9mwUX+ELhyWvtm+KzlmpLjpvNhaPfQCrsAk37tFLpGB+EEqMtbiDlnF/cIzdD qZ/fhOdjGEeLuJCH/EZdNYOjnsHTI77Dvfcsou/bBQC1QmNOm3C0f7atTnrdPFTul82r 1H33bxernjMykO17einmQNHkTpjsYF3hSFNhilZSkgZnsLtvPximtugqIhm/uF2IWlhx nhsYB25o1f/FgEp6f7WvoX0zM93d15G/HNdrUlKjtIWZJTQst9tnNHzBcqpFNw2z3I6s ckALMX9AcfgdtxfhGiZ49KSbaHQBg6oL+a0fuZboykCzrt4NuuyVqhH09+KtQuknxKns Wtpw== X-Received: by 10.60.97.67 with SMTP id dy3mr111438oeb.93.1381161391626; Mon, 07 Oct 2013 08:56:31 -0700 (PDT) MIME-Version: 1.0 From: Hauke Petersen Date: Mon, 7 Oct 2013 17:55:51 +0200 Message-ID: Subject: Inconsistent history expansion of characters adjacent to histchar To: zsh-workers@zsh.org Content-Type: text/plain; charset=ISO-8859-1 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.)