Bug 204039 - terminal messes up the bash history with too many "clear" and "cd" commands
Summary: terminal messes up the bash history with too many "clear" and "cd" commands
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: panels: terminal (show other bugs)
Version: 16.12.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Peter Penz
URL:
Keywords:
: 312512 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-16 13:00 UTC by Simon Dreher
Modified: 2013-01-03 08:11 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Dreher 2009-08-16 13:00:55 UTC
Version:           1.2.1 (using 4.2.4 (KDE 4.2.4), Debian packages)
Compiler:          cc
OS:                Linux (i686) release 2.6.30-1-686

In contrast to the former behavior of the terminal extension of Konqueror in KDE 3.5, any opening of a new window or change of a directory writes a clear or cd command to the bash history when the terminal view is open, so I don't find the relevant entries in the bash history.
Comment 1 Frank Reininghaus 2009-08-16 19:33:24 UTC
The "cd"s are needed to keep the terminal panel in sync with the current directory in the view. If you don't want that, you can open an external terminal in KDE 4.3, see bug 164746.

The "clear" command is supposed to hide the initial "cd" command. Removing it might be more annoying or irritating to most people than the "clear" in the history, I'm afraid...
Comment 2 Simon Dreher 2009-08-19 10:20:32 UTC
If I remember correctly, the former Konqueror addon didn't write
anything to the normal bash history, but kept its own history. So the
problem was limited to the small shell within the file manager, where
the additional cd and clear commands don't matter, as the shell in a
file manager is more like a helper application than a normal shell where
you are working. I think this behavior would be much more convenient.

The other problem with the current implementation of the directory
changes is that the command seems to be inserted even if the command
line isn't idle. For exaple if you have a
less <file>
running and change the directory, you get a "Pattern not found  (press
RETURN)". It is even worse if you have an editor like vim running in the
shell...
The same problem you get if you have just typed in a (part of) a command
and klick on a folder. Suppose you have your ripped music stored in a
folder "cd", want to remove something else, just typing "rm -r "
(perhaps because you need to do this as root) and click on a  folder
symbol (perhaps accidentially on the touch pad)... not a very funny
imagination. You see, this problem reaches from annoying to extremely
dangerous. Wouldn't it be possible to check if the command line is
really free?

Cheers, Simon
Comment 3 Frank Reininghaus 2009-08-19 10:27:39 UTC
(In reply to comment #2)
> The other problem with the current implementation of the directory
> changes is that the command seems to be inserted even if the command
> line isn't idle.

This is bug 161637.

> Wouldn't it be possible to check if the command line is
> really free?

I'm not a terminal expert, but I think this is not possible easily :-(
Comment 4 Simon Dreher 2009-08-24 19:33:41 UTC
Setting the bash variable HISTFILE to a separate file (for example somewhere in the KDE settings) or even clear it completely would be a major improvement, so at least the normal bash history would be clean.
Comment 5 Thorsten Mühlfelder 2010-03-01 19:40:54 UTC
Yes, this is a bit annoying. Would it be possible to prevent all "cd" commands from being saved in bash history?
Comment 6 Simon Dreher 2010-03-02 09:48:58 UTC
(In reply to comment #5)
> Yes, this is a bit annoying. Would it be possible to prevent all "cd" commands
> from being saved in bash history?

A possible solution could be to prepend a blank to the automagically created "clear" and "cd" commands. At least when bash is used and HISTCONTROL includes ignorespace or ignoreboth, these commands will not be added to the history (see the bash man page). Perhaps it is also possible to add at least ignorespace for the newly started bash?
Comment 7 whatmeurgent 2011-03-08 23:35:32 UTC
This seems to be very similar to a bug that I had wanted to originate, so instead of creating a new bug, I'll add some detail:

dolphin terminal will (kind of) spontaneously eliminate half-entered command lines.

This is a consequence of the 'feature' of the dolphin's terminal desire to always be in the folder reflected by the current focus of a panel elsewhere in dolphin.

01] open dolphin
02] f4 to open dolphin terminal
03] start to enter a long complicated command
04] f3 or ctrl-t and navigate to another folder
05] dolphin-terminal has replaced your unfinished command with a cd to the newly focused folder

What should happen
==================
01] do nothing; don't change directory, don't mess with command-line - my first choice
02] save the half-entered command; perform the cd; restore the half-entered command; - my second choice
03] half-entered command line could be stored in history (not-executed, of course), before the cd.
Comment 8 Frank Reininghaus 2012-06-03 20:59:43 UTC
(In reply to comment #6)
> A possible solution could be to prepend a blank to the automagically created
> "clear" and "cd" commands. At least when bash is used and HISTCONTROL
> includes ignorespace or ignoreboth, these commands will not be added to the
> history (see the bash man page). Perhaps it is also possible to add at least
> ignorespace for the newly started bash?

I must have missed this comment two years ago, sorry.

We've discussed this issue on the kfm-devel-list this week and decided to prepend the commands with a space, as you suggested. The change will be in KDE 4.9:

http://lists.kde.org/?t=133844952400003&r=1&w=2
Comment 9 Frank Reininghaus 2012-06-03 21:00:11 UTC
Git commit 78e790cb0383ef88903b689d359318bb6ab5c984 by Frank Reininghaus.
Committed on 03/06/2012 at 22:50.
Pushed by freininghaus into branch 'master'.

Prepend "cd" and "clear" commands with a space in the Terminal Panel

This prevents that these commands, which have not been enetered by the
user, but generated automatically, appear in the shell history, provided
that the shell is configured appropriately.
FIXED-IN: 4.9.0

M  +2    -2    dolphin/src/panels/terminal/terminalpanel.cpp

http://commits.kde.org/kde-baseapps/78e790cb0383ef88903b689d359318bb6ab5c984
Comment 10 oracle2b 2012-06-06 19:38:42 UTC
So this will appear in 4.9?
Comment 11 oracle2b 2012-06-06 19:41:54 UTC
thanks for the fix!
Comment 12 Frank Reininghaus 2012-06-07 07:50:35 UTC
(In reply to comment #10)
> So this will appear in 4.9?

Yes, see the "Version Fixed In" field here in the bug report or the "FIXED-IN" keyword in the commit message.
Comment 13 Frank Reininghaus 2013-01-03 08:11:30 UTC
*** Bug 312512 has been marked as a duplicate of this bug. ***