zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Workers <zsh-workers@zsh.org>
Subject: Re: !!$ unitialized at first prompt
Date: Fri, 24 Sep 2010 08:10:40 -0700	[thread overview]
Message-ID: <100924081042.ZM4496@torch.brasslantern.com> (raw)
In-Reply-To: <20100924133936.245765b2@pwslap01u.europe.root.pri>

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.

-- 


  parent reply	other threads:[~2010-09-24 15:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-24  4:36 Benjamin R. Haskell
2010-09-24  4:43 ` Benjamin R. Haskell
2010-09-24 11:48   ` Mikael Magnusson
2010-09-24 12:39     ` Peter Stephenson
2010-09-24 14:18       ` Benjamin R. Haskell
2010-09-24 14:26         ` Peter Stephenson
2010-09-24 15:30           ` Bart Schaefer
2010-09-24 15:10       ` Bart Schaefer [this message]
2010-09-24 15:20         ` Mikael Magnusson
2010-09-24 20:12         ` Peter Stephenson
2010-09-25  6:53           ` Bart Schaefer
2010-09-25 17:26             ` Wayne Davison
2010-09-25 18:49               ` Peter Stephenson
2010-09-26  1:14                 ` Bart Schaefer

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=100924081042.ZM4496@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).