Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Re: [Midnight Commander] #2104: using subshell makes bash clobber its history with some PS1-related (?) junk

1 view
Skip to first unread message

Ticket System

unread,
Sep 8, 2023, 8:41:17 AM9/8/23
to notor...@gmail.com, mc-...@googlegroups.com, mc-...@demonsphere.de, kyo...@yandex.ru
#2104: using subshell makes bash clobber its history with some PS1-related (?)
junk
----------------------------+---------------------------------------
Reporter: doktornotor | Owner:
Type: defect | Status: reopened
Priority: major | Milestone: Future Releases
Component: mc-core | Version: 4.7.1
Resolution: | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------
Changes (by Kyogre):

* cc: kyogre1@… (added)


--
Ticket URL: <http://www.midnight-commander.org/ticket/2104#comment:22>
Midnight Commander <https://midnight-commander.org>
Midnight Development Center

Ticket System

unread,
Oct 6, 2024, 11:29:13 AM10/6/24
to notor...@gmail.com, mc-...@googlegroups.com, mc-...@demonsphere.de, kyo...@yandex.ru
#2104: using subshell makes bash clobber its history with some PS1-related (?)
junk
----------------------------+---------------------------------------
Reporter: doktornotor | Owner:
Type: defect | Status: reopened
Priority: major | Milestone: Future Releases
Component: mc-core | Version: 4.7.1
Resolution: | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by zaytsev):

I have checked the source code and it seems that !BusyBox shells
(ash/hush) don't support HISTCONTROL. I've sent a patch to
bus...@busybox.net, for now it's bounced, no idea what happens next.

{{{
From 1165db3b3851e3fece948da669e9b520d4db37f9 Mon Sep 17 00:00:00 2001
From: "Yury V. Zaytsev" <yu...@shurup.com>
Date: Sun, 6 Oct 2024 15:03:19 +0200
Subject: [PATCH] lineedit: add basic support for bash-style HISTCONTROL
options

Signed-off-by: Yury V. Zaytsev <yu...@shurup.com>
---
libbb/lineedit.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 151208c1c..1cdf16cea 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1657,6 +1657,7 @@ static void save_history(char *str)
static void remember_in_history(char *str)
{
int i;
+ char *histcontrol;

if (!(state->flags & DO_HISTORY))
return;
@@ -1667,6 +1668,12 @@ static void remember_in_history(char *str)
if (i && strcmp(state->history[i-1], str) == 0)
return;

+ if ((histcontrol = getenv("HISTCONTROL"))
+ && (strstr(histcontrol, "ignorespace")
+ || strstr (histcontrol, "ignoreboth"))
+ && str[0] == ' ')
+ return;
+
free(state->history[state->max_history]); /* redundant, paranoia
*/
state->history[state->max_history] = NULL; /* redundant, paranoia
*/

--
2.46.2
}}}

It seems that csh/tcsh only supports this:

{{{
beastie@freebsd:~ $ csh
beastie@freebsd:~ $ unset savehist
}}}

No idea if we should set it when we fork the shell (but then user commands
will be lost as well) or there is some way to do our business forking new
instances all the time, but I guess not.

--
Ticket URL: <http://www.midnight-commander.org/ticket/2104#comment:23>

Ticket System

unread,
Oct 6, 2024, 11:56:06 AM10/6/24
to notor...@gmail.com, mc-...@googlegroups.com, mc-...@demonsphere.de, kyo...@yandex.ru
#2104: using subshell makes bash clobber its history with some PS1-related (?)
junk
----------------------------+---------------------------------------
Reporter: doktornotor | Owner:
Type: defect | Status: reopened
Priority: major | Milestone: Future Releases
Component: mc-core | Version: 4.7.1
Resolution: | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by zaytsev):

Dash also has the same problem, interesting to talk to the developers,
maybe they would agree to do HISTCONTROL:

http://gondor.apana.org.au/~herbert/dash/

--
Ticket URL: <http://www.midnight-commander.org/ticket/2104#comment:24>

Ticket System

unread,
Oct 6, 2024, 1:59:02 PM10/6/24
to notor...@gmail.com, mc-...@googlegroups.com, mc-...@demonsphere.de, kyo...@yandex.ru
#2104: using subshell makes bash clobber its history with some PS1-related (?)
junk
----------------------------+---------------------------------------
Reporter: doktornotor | Owner:
Type: defect | Status: reopened
Priority: major | Milestone: Future Releases
Component: mc-core | Version: 4.7.1
Resolution: | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by zaytsev):

https://lore.kernel.org/dash/36590CFE-D82B-4A0D-
A3A3-574...@shurup.com/T/#u

--
Ticket URL: <http://www.midnight-commander.org/ticket/2104#comment:25>

Ticket System

unread,
Oct 18, 2024, 3:28:17 AM10/18/24
to notor...@gmail.com, mc-...@googlegroups.com, mc-...@demonsphere.de, kyo...@yandex.ru
#2104: using subshell makes bash clobber its history with some PS1-related (?)
junk
----------------------------+---------------------------------------
Reporter: doktornotor | Owner:
Type: defect | Status: reopened
Priority: major | Milestone: Future Releases
Component: mc-core | Version: 4.7.1
Resolution: | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by zaytsev):

No luck with Busybox list, posted to Bugzilla instead:
https://bugs.busybox.net/show_bug.cgi?id=16213

--
Ticket URL: <http://www.midnight-commander.org/ticket/2104#comment:26>

Reply all
Reply to author
Forward
0 new messages