Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: !!$ unitialized at first prompt
- X-seq: zsh-workers 28292
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Workers <zsh-workers@xxxxxxx>
- Subject: Re: !!$ unitialized at first prompt
- Date: Fri, 24 Sep 2010 08:10:40 -0700
- In-reply-to: <20100924133936.245765b2@xxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1009232317460.4754@hp> <alpine.LNX.2.01.1009240037470.4754@hp> <AANLkTikvXfMnkWiZ0kay=s67X=UFhiSvhJGdU120=-6R@xxxxxxxxxxxxxx> <20100924133936.245765b2@xxxxxxxxxxxxxxxxxxxxxxxxx>
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.
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author