zsh-users
 help / color / mirror / code / Atom feed
* Unterminated command truncates history file
@ 2021-06-08 19:48 Jonathan Ching
  2021-06-08 20:14 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Ching @ 2021-06-08 19:48 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

Hello,

I have been searching for a way to resolve an issue in which issuing a
SIGINT via Ctrl-C to a "dquote> " prompt after an unterminated command
results in the history file being truncated, removing all but the first
line of the history file.

For example, following the command

echo "Hello

with a Ctrl-C at the "dquote> " prompt will cause the history file to be
truncated.

For context, I have the options "incappendhistory" and "extendedhistory" set

Is there a way to avoid this behavior?

[-- Attachment #2: Type: text/html, Size: 762 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Unterminated command truncates history file
  2021-06-08 19:48 Unterminated command truncates history file Jonathan Ching
@ 2021-06-08 20:14 ` Bart Schaefer
  2021-06-08 20:25   ` Jonathan Ching
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-06-08 20:14 UTC (permalink / raw)
  To: Jonathan Ching; +Cc: Zsh Users

On Tue, Jun 8, 2021 at 12:48 PM Jonathan Ching <jon48c@gmail.com> wrote:
>
> I have been searching for a way to resolve an issue in which issuing a SIGINT via Ctrl-C to a "dquote> " prompt after an unterminated command results in the history file being truncated, removing all but the first line of the history file.

I believe this is fixed by the patch in workers/44067


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Unterminated command truncates history file
  2021-06-08 20:14 ` Bart Schaefer
@ 2021-06-08 20:25   ` Jonathan Ching
  2021-06-08 20:41     ` Jonathan Ching
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Ching @ 2021-06-08 20:25 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

Ah, I see, thank you! I will give 5.8 a try

On Tue, Jun 8, 2021 at 1:14 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Tue, Jun 8, 2021 at 12:48 PM Jonathan Ching <jon48c@gmail.com> wrote:
> >
> > I have been searching for a way to resolve an issue in which issuing a
> SIGINT via Ctrl-C to a "dquote> " prompt after an unterminated command
> results in the history file being truncated, removing all but the first
> line of the history file.
>
> I believe this is fixed by the patch in workers/44067
>

[-- Attachment #2: Type: text/html, Size: 887 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Unterminated command truncates history file
  2021-06-08 20:25   ` Jonathan Ching
@ 2021-06-08 20:41     ` Jonathan Ching
  2021-06-08 20:59       ` Roman Perepelitsa
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Ching @ 2021-06-08 20:41 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

It doesn't seem like the issue is resolved by 5.8. Could it be something
else?

jching-mos:~% echo $ZSH_VERSION
5.8
jching-mos:~% stat -f %z ~/.zsh_history
2829751
jching-mos:~% echo "Hello
dquote>
jching-mos:~[130]% stat -f %z ~/.zsh_history
66


To add, $HISTFILESIZE and $HISTSIZE are both set to 9223372036854775807 (I
want to keep everything :) )

On Tue, Jun 8, 2021 at 1:25 PM Jonathan Ching <jon48c@gmail.com> wrote:

> Ah, I see, thank you! I will give 5.8 a try
>
> On Tue, Jun 8, 2021 at 1:14 PM Bart Schaefer <schaefer@brasslantern.com>
> wrote:
>
>> On Tue, Jun 8, 2021 at 12:48 PM Jonathan Ching <jon48c@gmail.com> wrote:
>> >
>> > I have been searching for a way to resolve an issue in which issuing a
>> SIGINT via Ctrl-C to a "dquote> " prompt after an unterminated command
>> results in the history file being truncated, removing all but the first
>> line of the history file.
>>
>> I believe this is fixed by the patch in workers/44067
>>
>

[-- Attachment #2: Type: text/html, Size: 1765 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Unterminated command truncates history file
  2021-06-08 20:41     ` Jonathan Ching
@ 2021-06-08 20:59       ` Roman Perepelitsa
  2021-06-08 21:03         ` Jonathan Ching
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2021-06-08 20:59 UTC (permalink / raw)
  To: Jonathan Ching; +Cc: Bart Schaefer, Zsh Users

On Tue, Jun 8, 2021 at 10:42 PM Jonathan Ching <jon48c@gmail.com> wrote:
>
> It doesn't seem like the issue is resolved by 5.8. Could it be something else?

I can reproduce this:

    % docker run -e TERM -it --rm zshusers/zsh:5.8 zsh
    7a7002248c6a# print 'HISTFILE=~/hist'              >>~/.zshrc
    7a7002248c6a# print 'HISTSIZE=9223372036854775807' >>~/.zshrc
    7a7002248c6a# print 'SAVEHIST=9223372036854775807' >>~/.zshrc
    7a7002248c6a# print 'setopt incappendhistory'      >>~/.zshrc
    7a7002248c6a# exec zsh
    7a7002248c6a# echo 1
    1
    7a7002248c6a# echo 2
    2
    7a7002248c6a# cat ~/hist
    echo 1
    echo 2
    cat ~/hist
    7a7002248c6a# echo "
    dquote>
    7a7002248c6a# cat ~/hist
    echo 1
    cat ~/hist

Replacing 9223372036854775807with mere 1000000000000000000 avoids the issue.

From my experience with zsh source code, it doesn't bother with
handling integer overflow, so I'm not sure how serious this bug is.

Roman.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Unterminated command truncates history file
  2021-06-08 20:59       ` Roman Perepelitsa
@ 2021-06-08 21:03         ` Jonathan Ching
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Ching @ 2021-06-08 21:03 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Bart Schaefer, Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1273 bytes --]

Hah, thank you! That's what I get with fiddling with large integers I
suppose... Setting to a *reasonably* lower number seems to have resolved
the issue!

On Tue, Jun 8, 2021 at 2:00 PM Roman Perepelitsa <
roman.perepelitsa@gmail.com> wrote:

> On Tue, Jun 8, 2021 at 10:42 PM Jonathan Ching <jon48c@gmail.com> wrote:
> >
> > It doesn't seem like the issue is resolved by 5.8. Could it be something
> else?
>
> I can reproduce this:
>
>     % docker run -e TERM -it --rm zshusers/zsh:5.8 zsh
>     7a7002248c6a# print 'HISTFILE=~/hist'              >>~/.zshrc
>     7a7002248c6a# print 'HISTSIZE=9223372036854775807' >>~/.zshrc
>     7a7002248c6a# print 'SAVEHIST=9223372036854775807' >>~/.zshrc
>     7a7002248c6a# print 'setopt incappendhistory'      >>~/.zshrc
>     7a7002248c6a# exec zsh
>     7a7002248c6a# echo 1
>     1
>     7a7002248c6a# echo 2
>     2
>     7a7002248c6a# cat ~/hist
>     echo 1
>     echo 2
>     cat ~/hist
>     7a7002248c6a# echo "
>     dquote>
>     7a7002248c6a# cat ~/hist
>     echo 1
>     cat ~/hist
>
> Replacing 9223372036854775807with mere 1000000000000000000 avoids the
> issue.
>
> From my experience with zsh source code, it doesn't bother with
> handling integer overflow, so I'm not sure how serious this bug is.
>
> Roman.
>

[-- Attachment #2: Type: text/html, Size: 1854 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-08 21:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 19:48 Unterminated command truncates history file Jonathan Ching
2021-06-08 20:14 ` Bart Schaefer
2021-06-08 20:25   ` Jonathan Ching
2021-06-08 20:41     ` Jonathan Ching
2021-06-08 20:59       ` Roman Perepelitsa
2021-06-08 21:03         ` Jonathan Ching

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).