From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24637 invoked by alias); 24 Sep 2010 15:11:01 -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: 28292 Received: (qmail 2278 invoked from network); 24 Sep 2010 15:10:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <100924081042.ZM4496@torch.brasslantern.com> Date: Fri, 24 Sep 2010 08:10:40 -0700 In-reply-to: <20100924133936.245765b2@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: !!$ unitialized at first prompt" (Sep 24, 1:39pm) References: <20100924133936.245765b2@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Workers Subject: Re: !!$ unitialized at first prompt MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 24, 1:39pm, Peter Stephenson wrote: } } The shell doesn't split words in the same way when importing history. } In normal operation it relies on the lines having been passed through } the lexical analyser to generate the words, which doesn't happen when } history is read from a file. Instead it just blindly splits on } whitespace. ... and at the time this was designed, it would make history import an agonizingly slow process if the entire history file had to be passed through the lexical analyzer. Nowadays that's probably not so much a concern for most people. There's probably an argument to be made that SHARE_HISTORY should force use of the lexical analyzer, because (although no one has ever complained) the current implementation means that history words referenced from shared history behave differently than those from the local history. You can load your own history something like this provided that you *don't* use shared or extended history: readhistfile() { emulate -LR zsh local histline local -a histwords while read -r histline do if [[ $histline = *\\ ]] then histline[-1]='' histwords+=( ${(z)histline}$'\n' ) else histwords+=( ${(z)histline} ) print -s $histwords histwords=() fi done } That's not perfect, as it does things like insert a space at the front of every continuation line in a multi-line command, but it's passable. Note the function as written expects the history to be standard input. --