Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: $history[@] doesn't contain last element from $HISTFILE



On Fri, Oct 14, 2016 at 11:35 AM, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> It's fine if it's not an unpredictable thing, I can stick to the
> workaround (now not actually a workaround), not having to do an
> is-at-least call in return. Although I'm not sure if by
> $history[$HISTNO] you mean $history[$size], if there is something
> unexpected there, it would be a problem.

$history is not an array, it's a hash whose keys are the history event
numbers.  So (( $#history < HISTSIZE )) is always true but (( HISTNO >
HISTSIZE )) is possible.  The largest possible defined index into
$history is $HISTNO, but of course that's only valid inside ZLE.

If you're manipulating history in an "fc -p" scope or the like there's
really only $(( ${${(k)history[@]}[1]} + 1)) to get the equivalent,
which does seem like an oversight.



Messages sorted by: Reverse Date, Date, Thread, Author