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

Re: delay in exitting from zsh shell

On Nov 10,  9:19am, Eugene Dzhurinsky wrote:
} Okay, I wrote stupid and simple program to de-duplicate lines in
} history file:

You can't compare that to what zsh is doing.  The history file isn't
just duplicate lines, it's duplicate shell parser constructs which
may span multiple lines.  The only way to _correctly_ deduplicate it
is to run it through the parser while loading it; that's where all
the time/CPU is going.

} Am I missing something there if would say that history saving and
} de-duplication is suboptimal?

If a special routine that does nothing but deduplicate the file were
to be added, it could probably be faster, yes.  The history mechanism
performs the deduplication by loading the file back in roughly as if
all the commands were being typed at the command line again, so that
the behavior of deduplication exactly reproduces what the shell would
have done interactively with all the setopts that are in effect.

This is simply not an operation that's done often enough -- nor is
having 10000+ lines of shared deduplicated history a common enough user
configuration -- for anyone to have undertaken to create an efficient
deduplication routine that nevertheless faithfully reproduces the
behavior of re-parsing the file.  Feel free to contribute that ...

However, it might be simpler just to unset the options that cause the
file to be deduped on shell exit, and e.g. allow it to be deduped on
shell startup instead.

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