unofficial mirror of emacs-tangents@gnu.org
 help / color / mirror / Atom feed
* Re: [OT] Not clobbering bash history
       [not found]             ` <87v89ujwa6.fsf@aarsen.me>
@ 2023-11-22 20:43               ` Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2023-11-22 21:50                 ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
       [not found]               ` <E1r6isT-000665-Pt@fencepost.gnu.org>
  1 sibling, 1 reply; 18+ messages in thread
From: Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-11-22 20:43 UTC (permalink / raw)
  To: Arsen Arsenović, rms; +Cc: brickviking, sbaugh, luangruo, emacs-tangents

Moving to tangents ... please CC me.

On 2023-11-22  04:32, Arsen Arsenović wrote:

>> Should we suggest that the Bash developer add a feature to handle this
>> case (multiple shells in parallel) the "right" way?  If many users
>> would like it, that could make it worth building in.
> 
> That would be very nice.  This issue has almost been prolific enough to
> force me to switch shells.

This Bash-bashing made me curious, as I do not remember having issues with
loss of its history, ever.  And that without such tricks as using an ever
growing history file.  I just use "shopt -s histappend" and 4096 lines as
HISTFILESIZE.  Plus I close my Bashes orderly before shutting down.  Plus
I do not use Bash from Emacs, only in "real" terminals.  Eh, plus I rarely
use nested Bashes.

So given all that, is there a reproducer for this?

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-11-22 20:43               ` [OT] Not clobbering bash history Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
@ 2023-11-22 21:50                 ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2023-11-23 12:42                   ` Spencer Baugh
  0 siblings, 1 reply; 18+ messages in thread
From: Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-11-22 21:50 UTC (permalink / raw)
  To: Jens Schmidt; +Cc: rms, brickviking, sbaugh, luangruo, emacs-tangents


[-- Attachment #1.1: Type: text/plain, Size: 1713 bytes --]


Jens Schmidt <jschmidt4gnu@vodafonemail.de> writes:

> Moving to tangents ... please CC me.
>
> On 2023-11-22  04:32, Arsen Arsenović wrote:
>
>>> Should we suggest that the Bash developer add a feature to handle this
>>> case (multiple shells in parallel) the "right" way?  If many users
>>> would like it, that could make it worth building in.
>> 
>> That would be very nice.  This issue has almost been prolific enough to
>> force me to switch shells.
>
> This Bash-bashing made me curious, as I do not remember having issues
> with loss of its history, ever.

I do not partake in bash-bashing enthusiastically.  I'm a big fan of
readline and appreciate how reliable bash is.

> And that without such tricks as using an ever growing history file.  I
> just use "shopt -s histappend" and 4096 lines as HISTFILESIZE.  Plus I
> close my Bashes orderly before shutting down.  Plus I do not use Bash
> from Emacs, only in "real" terminals.  Eh, plus I rarely use nested
> Bashes.
>
> So given all that, is there a reproducer for this?

Unfortunately, I have been unable to produce a decent set of
reproduction steps.  This issue happens (relatively) infrequently and
inexplicably on my machines.  It pains me to complain without solid
information.

I also have shopt -s histappend set.

I suspect that something starts a bash process and does not set
histappend (--norc?), leading bash to override history.

I wonder whether, in general, if bash (libhistory?) was written with the
assumption of multiple processes writing to the history file, so that it
keeps its history in sync with other bash processes, problems of this
category would go away.
-- 
Arsen Arsenović

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-11-22 21:50                 ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
@ 2023-11-23 12:42                   ` Spencer Baugh
  2023-11-23 20:12                     ` Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  0 siblings, 1 reply; 18+ messages in thread
From: Spencer Baugh @ 2023-11-23 12:42 UTC (permalink / raw)
  To: Arsen Arsenović, Jens Schmidt
  Cc: rms, brickviking, luangruo, emacs-tangents

Arsen Arsenović <arsen@aarsen.me> writes:
> Jens Schmidt <jschmidt4gnu@vodafonemail.de> writes:
>
>> Moving to tangents ... please CC me.
>>
>> On 2023-11-22  04:32, Arsen Arsenović wrote:
>>
>>>> Should we suggest that the Bash developer add a feature to handle this
>>>> case (multiple shells in parallel) the "right" way?  If many users
>>>> would like it, that could make it worth building in.
>>> 
>>> That would be very nice.  This issue has almost been prolific enough to
>>> force me to switch shells.
>>
>> This Bash-bashing made me curious, as I do not remember having issues
>> with loss of its history, ever.
>
> I do not partake in bash-bashing enthusiastically.  I'm a big fan of
> readline and appreciate how reliable bash is.
>
>> And that without such tricks as using an ever growing history file.  I
>> just use "shopt -s histappend" and 4096 lines as HISTFILESIZE.  Plus I
>> close my Bashes orderly before shutting down.  Plus I do not use Bash
>> from Emacs, only in "real" terminals.  Eh, plus I rarely use nested
>> Bashes.
>>
>> So given all that, is there a reproducer for this?
>
> Unfortunately, I have been unable to produce a decent set of
> reproduction steps.  This issue happens (relatively) infrequently and
> inexplicably on my machines.  It pains me to complain without solid
> information.
>
> I also have shopt -s histappend set.
>
> I suspect that something starts a bash process and does not set
> histappend (--norc?), leading bash to override history.

I've always suspected TRAMP of this.

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-11-23 12:42                   ` Spencer Baugh
@ 2023-11-23 20:12                     ` Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  0 siblings, 0 replies; 18+ messages in thread
From: Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-11-23 20:12 UTC (permalink / raw)
  To: Spencer Baugh, Arsen Arsenović
  Cc: rms, brickviking, luangruo, emacs-tangents

On 2023-11-23  13:42, Spencer Baugh wrote:
> Arsen Arsenović <arsen@aarsen.me> writes:
>
>> Unfortunately, I have been unable to produce a decent set of
>> reproduction steps.  This issue happens (relatively) infrequently and
>> inexplicably on my machines.  It pains me to complain without solid
>> information.
>>
>> I also have shopt -s histappend set.
>>
>> I suspect that something starts a bash process and does not set
>> histappend (--norc?), leading bash to override history.
> 
> I've always suspected TRAMP of this.

Arsen's problem description rang a bell ... on my development server
at work I configure a non-standard history file in my .bashrc.  And
regardless of that, every now and then, the default ~/.bash_history
gets created.

So probably a work-around for your overwrite problems could be exactly
that: Just configure HISTFILE=~/.my_hidden_bash_history near the same
spot where you set 'shopt -s histappend'.  Any villain not respecting
the latter won't (hopefully) respect the former as well, leaving your
non-default Bash history untouched.  (Unless you have tried that
already, of course.)

Besides that, the contents and timestamp of the default ~/.bash_history,
should it still get created, could then help finding the villain.


---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
       [not found]                     ` <864jgy85g5.fsf@aarsen.me>
@ 2023-12-07  2:49                       ` Richard Stallman
  2023-12-07  5:34                         ` mbork
                                           ` (2 more replies)
  2023-12-08  3:54                       ` Richard Stallman
  1 sibling, 3 replies; 18+ messages in thread
From: Richard Stallman @ 2023-12-07  2:49 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: brickviking, sbaugh, luangruo, emacs-tangents

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I moved this to emacs-tangents because thus isn't really about Emacs,
but I don't know of a Bash list to use.  Is there one?

  > Say that the history has eight entries, and a ninth was added by a
  > parallel process, the current process would be at the point after the
  > eighth element and should continue reading from there next time it wants
  > a history entry.

Are you saying that multiple Bash processes in parallel should share
one single history, which would contain all the commands the user
entered in any of these processes?

So the commands of Basb process A and those of Basb process B would be
interspersed in the history?  And as you go forward and back in the
history in Bash process B, you would see A's commands and B's commands
in chronological order?

That makes a kind of sense, but what I would envision is that each
Bash process has its own history with only the commands of that process.

Why do you prefer the shared history file approach
to the one-history-per-process approach?
-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)



---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  2:49                       ` Richard Stallman
@ 2023-12-07  5:34                         ` mbork
  2023-12-07  5:48                           ` Emanuel Berg
  2023-12-07  5:52                           ` Yuri Khan
  2023-12-07  6:44                         ` Jean Louis
  2023-12-07 13:06                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2 siblings, 2 replies; 18+ messages in thread
From: mbork @ 2023-12-07  5:34 UTC (permalink / raw)
  To: rms
  Cc: Arsen Arsenović, brickviking, sbaugh, luangruo,
	emacs-tangents


On 2023-12-06, at 21:49, Richard Stallman <rms@gnu.org> wrote:

> That makes a kind of sense, but what I would envision is that each
> Bash process has its own history with only the commands of that process.
>
> Why do you prefer the shared history file approach
> to the one-history-per-process approach?

Isn't it obvious?  If I have several terminals open at the same time
(and I seldom have fewer than, say, three, usually more), sharing
history is very useful.  It easy to remember that I issued some kind of
command, but much more difficult to remember in which terminal I did it.
Sharing history lessens my cognitive load.

Also, when I exit bash, the history is written to ~/.bash_history.  So,
if I have two bash sessions, they share the common history from that
file, but not common history from /this session/.  So the "every bash
process has a separate history" is not even true -- /part/ of the
history is shared.  Again, remembering which part adds to the cognitive
load.

Sharing history "live" makes it much simpler.

-- 
Marcin Borkowski
https://mbork.pl

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  5:34                         ` mbork
@ 2023-12-07  5:48                           ` Emanuel Berg
  2023-12-07  9:34                             ` mbork
  2023-12-07  5:52                           ` Yuri Khan
  1 sibling, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2023-12-07  5:48 UTC (permalink / raw)
  To: emacs-tangents

mbork wrote:

>> That makes a kind of sense, but what I would envision is
>> that each Bash process has its own history with only the
>> commands of that process.
>>
>> Why do you prefer the shared history file approach to the
>> one-history-per-process approach?
>
> Isn't it obvious? If I have several terminals open at the
> same time (and I seldom have fewer than, say, three, usually
> more), sharing history is very useful. It easy to remember
> that I issued some kind of command, but much more difficult
> to remember in which terminal I did it. Sharing history
> lessens my cognitive load.

How do you access history? One item at a time?

Because if you do one task in one terminal, maybe vading
through history one item at a time will then be annoying since
items from everywhere else, from other tasks, will make you
have to cycle a lot before you find what you look for?

Not saying you are wrong, just the discussion can go both ways.
I'm not a history user myself, really, but my zsh history
isn't shared between tmux panes. Not in xterm, not in the
Linux console.

But I never gave it any thought until now.

-- 
underground experts united
https://dataswamp.org/~incal


---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  5:34                         ` mbork
  2023-12-07  5:48                           ` Emanuel Berg
@ 2023-12-07  5:52                           ` Yuri Khan
  2023-12-07  6:22                             ` Emanuel Berg
  1 sibling, 1 reply; 18+ messages in thread
From: Yuri Khan @ 2023-12-07  5:52 UTC (permalink / raw)
  To: mbork
  Cc: rms, Arsen Arsenović, brickviking, sbaugh, luangruo,
	emacs-tangents

On Thu, 7 Dec 2023 at 12:40, <mbork@mbork.pl> wrote:

> Isn't it obvious?  If I have several terminals open at the same time
> (and I seldom have fewer than, say, three, usually more), sharing
> history is very useful.  It easy to remember that I issued some kind of
> command, but much more difficult to remember in which terminal I did it.

To add to this: The original terminal where I issued the command I
need might be busy, e.g. if I started some application in it. It might
be inconvenient to suspend that application just to get at the
command. Important special case: the application that’s occupying the
terminal where the original command was entered is Midnight Commander
running a sub-shell in which I want to repeat that command.

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  5:52                           ` Yuri Khan
@ 2023-12-07  6:22                             ` Emanuel Berg
  0 siblings, 0 replies; 18+ messages in thread
From: Emanuel Berg @ 2023-12-07  6:22 UTC (permalink / raw)
  To: emacs-tangents

Yuri Khan wrote:

>> Isn't it obvious? If I have several terminals open at the
>> same time (and I seldom have fewer than, say, three,
>> usually more), sharing history is very useful. It easy to
>> remember that I issued some kind of command, but much more
>> difficult to remember in which terminal I did it.
>
> To add to this: The original terminal where I issued the
> command I need might be busy, e.g. if I started some
> application in it. It might be inconvenient to suspend that
> application just to get at the command. Important special
> case: the application that’s occupying the terminal where
> the original command was entered is Midnight Commander
> running a sub-shell in which I want to repeat that command.

Can you have both? Local history and global history.

You have a command to switch which one is at play. 'gh' for
global history, 'lh' for local and 'th' for toggle.

That way you would also see what you would use. It is possible
you would actually just use the global one as you say.

How do I get global history for zsh?

I have this file in play - it sounds like global history, but
maybe it is session local, then? So it should be "live"
between sessions as well? How do you get that?

#! bin/zsh
#
# this file:
#   https://dataswamp.org/~incal/conf/.zsh/history

setopt appendhistory
setopt histignorealldups

HISTSIZE=1000
SAVEHIST=$(( 10 * $HISTSIZE ))

HISTFILE=~/.zsh-history

-- 
underground experts united
https://dataswamp.org/~incal


---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  2:49                       ` Richard Stallman
  2023-12-07  5:34                         ` mbork
@ 2023-12-07  6:44                         ` Jean Louis
  2023-12-11 12:09                           ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2023-12-07 13:06                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2 siblings, 1 reply; 18+ messages in thread
From: Jean Louis @ 2023-12-07  6:44 UTC (permalink / raw)
  To: Richard Stallman
  Cc: Arsen ArsenoviÄ?, brickviking, sbaugh, luangruo,
	emacs-tangents

>   > Say that the history has eight entries, and a ninth was added by a
>   > parallel process, the current process would be at the point after the
>   > eighth element and should continue reading from there next time it wants
>   > a history entry.

Arsen, explore options of the command `history' to do what you want,
you can save history:

$ history -a

and you can re-read history file:

$ history -r

and by using those options you can mix history from different Bash
sessions, and also re-use the history from other Bash session.



Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  5:48                           ` Emanuel Berg
@ 2023-12-07  9:34                             ` mbork
  0 siblings, 0 replies; 18+ messages in thread
From: mbork @ 2023-12-07  9:34 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: emacs-tangents


On 2023-12-07, at 06:48, Emanuel Berg <incal@dataswamp.org> wrote:

> mbork wrote:
>
>>> That makes a kind of sense, but what I would envision is
>>> that each Bash process has its own history with only the
>>> commands of that process.
>>>
>>> Why do you prefer the shared history file approach to the
>>> one-history-per-process approach?
>>
>> Isn't it obvious? If I have several terminals open at the
>> same time (and I seldom have fewer than, say, three, usually
>> more), sharing history is very useful. It easy to remember
>> that I issued some kind of command, but much more difficult
>> to remember in which terminal I did it. Sharing history
>> lessens my cognitive load.
>
> How do you access history? One item at a time?

Either that, or C-r (i.e., searching), depending on the situation.

> Because if you do one task in one terminal, maybe vading
> through history one item at a time will then be annoying since
> items from everywhere else, from other tasks, will make you
> have to cycle a lot before you find what you look for?

Good point.

Best,

-- 
Marcin Borkowski
https://mbork.pl

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  2:49                       ` Richard Stallman
  2023-12-07  5:34                         ` mbork
  2023-12-07  6:44                         ` Jean Louis
@ 2023-12-07 13:06                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  2023-12-08  3:56                           ` Richard Stallman
  2 siblings, 1 reply; 18+ messages in thread
From: Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-12-07 13:06 UTC (permalink / raw)
  To: rms; +Cc: brickviking, sbaugh, luangruo, emacs-tangents


[-- Attachment #1.1: Type: text/plain, Size: 2131 bytes --]


Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> I moved this to emacs-tangents because thus isn't really about Emacs,
> but I don't know of a Bash list to use.  Is there one?

IIRC there's bug-bash and it accepts patches, so it is perhaps also
appropriate for topics like this one.

>   > Say that the history has eight entries, and a ninth was added by a
>   > parallel process, the current process would be at the point after the
>   > eighth element and should continue reading from there next time it wants
>   > a history entry.
>
> Are you saying that multiple Bash processes in parallel should share
> one single history, which would contain all the commands the user
> entered in any of these processes?

Yes.  Opinions vary on this, but I have a workflow which relies on this
(via a hack I put in my bashrc and found ages ago).

> So the commands of Basb process A and those of Basb process B would be
> interspersed in the history?  And as you go forward and back in the
> history in Bash process B, you would see A's commands and B's commands
> in chronological order?

Yes.  ZSH does implement this well IME (but I haven't used ZSH
extensively.. so I'm not sure if I'd run into trouble with it).

> That makes a kind of sense, but what I would envision is that each
> Bash process has its own history with only the commands of that process.

Some do prefer that.  It'd be reasonable to do that by default, as it's
currently the default.

> Why do you prefer the shared history file approach
> to the one-history-per-process approach?

Because I rely on working in many, many interactive shells in parallel.

Though, on that note, it is perhaps reasonable to flip 'histappend' to
on by default, even if nothing else changes (because otherwise history
is lost since only the last shells history is kept).

Thanks, have a lovely day.
-- 
Arsen Arsenović

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
       [not found]                     ` <864jgy85g5.fsf@aarsen.me>
  2023-12-07  2:49                       ` Richard Stallman
@ 2023-12-08  3:54                       ` Richard Stallman
  2023-12-08  6:22                         ` brickviking
  2023-12-08 10:13                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  1 sibling, 2 replies; 18+ messages in thread
From: Richard Stallman @ 2023-12-08  3:54 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: brickviking, sbaugh, luangruo, emacs-tangents

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > If two different shells will try to write history into one single file,
  > > are they doomed to give bad results, one way or another...

  > Not necessarily.  If both shells use a single write() syscall on an
  > O_APPEND file, they should work as expected to my awareness.

We are miscommunicating.  The way you expect it to work is, in my
opinion, a bad result -- various histories interspersed.

It seems to me that the crucial thing is for each Bash process
to have its own separate history.

Do you think that behavior would be bad?

  > If a bash process decides to rotate the history file as a result of
  > HISTSIZE, and another bash process decides to do the same, one of their
  > new history entries would be lost due to the other one overriding it.
  > This would be a bug.

Only if they share one single history file.  If each has its own
history file, each can handle it as if it were your only Bash process.


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)



---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07 13:06                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
@ 2023-12-08  3:56                           ` Richard Stallman
  2023-12-08 10:15                             ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  0 siblings, 1 reply; 18+ messages in thread
From: Richard Stallman @ 2023-12-08  3:56 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: brickviking, sbaugh, luangruo, emacs-tangents

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > So the commands of Basb process A and those of Basb process B would be
  > > interspersed in the history?  And as you go forward and back in the
  > > history in Bash process B, you would see A's commands and B's commands
  > > in chronological order?

  > Yes.  ZSH does implement this well IME (but I haven't used ZSH
  > extensively.. so I'm not sure if I'd run into trouble with it).

  > > That makes a kind of sense, but what I would envision is that each
  > > Bash process has its own history with only the commands of that process.

  > Some do prefer that.  It'd be reasonable to do that by default, as it's
  > currently the default.

It seems fine to support both modes and let each user choose.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)



---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-08  3:54                       ` Richard Stallman
@ 2023-12-08  6:22                         ` brickviking
  2023-12-08 10:13                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  1 sibling, 0 replies; 18+ messages in thread
From: brickviking @ 2023-12-08  6:22 UTC (permalink / raw)
  To: emacs-tangents; +Cc: Arsen Arsenović, sbaugh, luangruo, rms


[-- Attachment #1.1: Type: text/plain, Size: 3034 bytes --]

Please continue to CC: me on this thread, as I'm no longer part of the
emacs-devel
mailing list for the moment.

On Fri, 8 Dec 2023 at 16:54, Richard Stallman <rms@gnu.org> wrote:

>   > > If two different shells will try to write history into one single
> file,
>   > > are they doomed to give bad results, one way or another...
>
>   > Not necessarily.  If both shells use a single write() syscall on an
>   > O_APPEND file, they should work as expected to my awareness.
>
> We are miscommunicating.  The way you expect it to work is, in my
> opinion, a bad result -- various histories interspersed.
>
> It seems to me that the crucial thing is for each Bash process
> to have its own separate history.
>
> Do you think that behavior would be bad?
>
>
In my opinion, if I wanted to search for a command I'd previously run that
wasn't in my current bash shell history, how would the respective histories
be created?
Would it involve .bash_history.${PID},  or would it involve
.bash_history.${CURRENT_TIMESTAMP} (whatever form that took),
or some other combination?

In each case, bash can already look up its own history, but when a new Bash
shell is
started, just which history file is it going to load if there are multiple
bash history files
saved to disk? The latest by ${CURRENT_TIMESTAMP}? The highest ${PID}?
And where will subsequent history be written to? A new ${PID} file?

People who run multiple shells in parallel are probably well aware of this
now, and I expect that is why decisions were made way back when, to support
one history file. The only real argument is whether that history gets
erased when a current bash shell closes out and saves its own history over
the top (sort of handled by histappend, but not entirely.)

  > If a bash process decides to rotate the history file as a result of
>   > HISTSIZE, and another bash process decides to do the same, one of their
>   > new history entries would be lost due to the other one overriding it.
>   > This would be a bug.
>
> Only if they share one single history file.  If each has its own
> history file, each can handle it as if it were your only Bash process.
>
>
I must admit to having thought that histories could be stored in a sqlite3
database,
that way rotation of expired entries (date or number of lines) could be
handled by the
database itself. However, this means yet another dependency added to the
chain
where you might not have wished one. And in addition, the licence that
sqlite3 is provided
under is not a GNU licence, it's one of those licences that pretty much says
"We donate this to the public at large" (my summary, not theirs).

Another disadvantage for sqlite as a dependency, is that it's not the
simplest solution
feasible. It is darn quick though, and its development is certainly current
and ongoing.
One advantage to making the history as a single file (flat or database) is
to make
searching easier, but that's also its Achilles heel when you want to rotate
the file if you're running
multiple bash shells.

Regards, brickviking

[-- Attachment #1.2: Type: text/html, Size: 4023 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-08  3:54                       ` Richard Stallman
  2023-12-08  6:22                         ` brickviking
@ 2023-12-08 10:13                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  1 sibling, 0 replies; 18+ messages in thread
From: Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-12-08 10:13 UTC (permalink / raw)
  To: rms; +Cc: brickviking, sbaugh, luangruo, emacs-tangents


[-- Attachment #1.1: Type: text/plain, Size: 1646 bytes --]


Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > > If two different shells will try to write history into one single file,
>   > > are they doomed to give bad results, one way or another...
>
>   > Not necessarily.  If both shells use a single write() syscall on an
>   > O_APPEND file, they should work as expected to my awareness.
>
> We are miscommunicating.  The way you expect it to work is, in my
> opinion, a bad result -- various histories interspersed.
>
> It seems to me that the crucial thing is for each Bash process
> to have its own separate history.
>
> Do you think that behavior would be bad?

Bad?  No.  It's not what I'd prefer, though.

Note that, with either separate or interspersed histories, history
should never be lost, so, if a file is being shared by multiple shells
(even if it is not continuously re-read), care should be taken not to
lose data.

>   > If a bash process decides to rotate the history file as a result of
>   > HISTSIZE, and another bash process decides to do the same, one of their
>   > new history entries would be lost due to the other one overriding it.
>   > This would be a bug.
>
> Only if they share one single history file.  If each has its own
> history file, each can handle it as if it were your only Bash process.

Indeed.  How would these histories be recalled, though?  Which file does
a new shell read?
-- 
Arsen Arsenović

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-08  3:56                           ` Richard Stallman
@ 2023-12-08 10:15                             ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  0 siblings, 0 replies; 18+ messages in thread
From: Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-12-08 10:15 UTC (permalink / raw)
  To: rms; +Cc: brickviking, sbaugh, luangruo, emacs-tangents


[-- Attachment #1.1: Type: text/plain, Size: 1059 bytes --]


Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > > So the commands of Basb process A and those of Basb process B would be
>   > > interspersed in the history?  And as you go forward and back in the
>   > > history in Bash process B, you would see A's commands and B's commands
>   > > in chronological order?
>
>   > Yes.  ZSH does implement this well IME (but I haven't used ZSH
>   > extensively.. so I'm not sure if I'd run into trouble with it).
>
>   > > That makes a kind of sense, but what I would envision is that each
>   > > Bash process has its own history with only the commands of that process.
>
>   > Some do prefer that.  It'd be reasonable to do that by default, as it's
>   > currently the default.
>
> It seems fine to support both modes and let each user choose.

I agree.
-- 
Arsen Arsenović

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

* Re: [OT] Not clobbering bash history
  2023-12-07  6:44                         ` Jean Louis
@ 2023-12-11 12:09                           ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
  0 siblings, 0 replies; 18+ messages in thread
From: Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists @ 2023-12-11 12:09 UTC (permalink / raw)
  To: Jean Louis
  Cc: Richard Stallman, brickviking, sbaugh, luangruo, emacs-tangents


[-- Attachment #1.1: Type: text/plain, Size: 1093 bytes --]

Hi Jean,

Jean Louis <bugs@gnu.support> writes:

>>   > Say that the history has eight entries, and a ninth was added by a
>>   > parallel process, the current process would be at the point after the
>>   > eighth element and should continue reading from there next time it wants
>>   > a history entry.
>
> Arsen, explore options of the command `history' to do what you want,
> you can save history:
>
> $ history -a
>
> and you can re-read history file:
>
> $ history -r
>
> and by using those options you can mix history from different Bash
> sessions, and also re-use the history from other Bash session.

Thanks for the tip.  I already have something using these flags
implemented:

  PROMPT_COMMAND="$PROMPT_COMMAND;history -a; history -c; history -r")

which is a functional hack, for the most part.  It still has some of the
problems mentioned in my original message (history is only added to
after a command concludes, sporadic truncation still happens, etc), plus
this approach is rather ugly.

Thanks again, have a lovely day.
-- 
Arsen Arsenović

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

---
via emacs-tangents mailing list (https://lists.gnu.org/mailman/listinfo/emacs-tangents)

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

end of thread, other threads:[~2023-12-11 12:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87wmufm7r7.fsf@catern.com>
     [not found] ` <87fs12jkik.fsf@yahoo.com>
     [not found]   ` <d858823d-d95a-1865-7331-671e3fa6b4e4@gutov.dev>
     [not found]     ` <s0d34x1q050.fsf@yahoo.com>
     [not found]       ` <87ttphlqlo.fsf@catern.com>
     [not found]         ` <CAHWye8693z4hSJgEosPH9_ZrH88F5dbWXPS78EdfeT393FYG7g@mail.gmail.com>
     [not found]           ` <E1r5dUV-00019J-Gz@fencepost.gnu.org>
     [not found]             ` <87v89ujwa6.fsf@aarsen.me>
2023-11-22 20:43               ` [OT] Not clobbering bash history Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2023-11-22 21:50                 ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2023-11-23 12:42                   ` Spencer Baugh
2023-11-23 20:12                     ` Jens Schmidt via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
     [not found]               ` <E1r6isT-000665-Pt@fencepost.gnu.org>
     [not found]                 ` <86il5g9qs9.fsf@aarsen.me>
     [not found]                   ` <E1r9zM4-000405-Gg@fencepost.gnu.org>
     [not found]                     ` <864jgy85g5.fsf@aarsen.me>
2023-12-07  2:49                       ` Richard Stallman
2023-12-07  5:34                         ` mbork
2023-12-07  5:48                           ` Emanuel Berg
2023-12-07  9:34                             ` mbork
2023-12-07  5:52                           ` Yuri Khan
2023-12-07  6:22                             ` Emanuel Berg
2023-12-07  6:44                         ` Jean Louis
2023-12-11 12:09                           ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2023-12-07 13:06                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2023-12-08  3:56                           ` Richard Stallman
2023-12-08 10:15                             ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2023-12-08  3:54                       ` Richard Stallman
2023-12-08  6:22                         ` brickviking
2023-12-08 10:13                         ` Arsen Arsenović via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists

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 read-only IMAP folder(s) and NNTP newsgroup(s).