[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: history issue - bug?



On Sun, 14 Jan 2018, Hans wrote:

Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
Hi David,

thanks for enlightening me. I always though, that "history -c" would
clear all the history and its files as the help file says:

-c        clear the history list by deleting all of the entries

So IMO this should delete all related history files, even
bash_history.

"Even" bash_history? Besides .bash_history, what other files did you
have in mind?

If "history -c" deleted any file at all, the documentation would need
to be changed to reflect that fact. At present, the documentation is
accurate.

A list has entries, and if you delete all the entries, that means you
now have an empty list. It certainly does NOT mean that you have
thereby nuked any and all files to which (the at-most $HISTSIZE length
tails of) previous iterations of that list have been saved.

I suspect that you must be distressed to discover a workflow you had
relied on does not in fact accomplish what you had long thought it
accomplished, because you had conceptually conflated two distinct
entities:

 * your shell *session's* command history *list*

versus

 * your *account's* command history *file*.

Speaking from repeated experience, it does indeed suck to learn that
your beliefs about a trusted tool's behavior have been mistaken for a
long time.

If this is the case, you have my condolences.

But you also have my congratulations, and perhaps you will agree that
finding out you were wrong is still far better than the alternative,
which is to remain forever blissfully mistaken.

And as far as I remember, this did it do in former times.

In my eyes this is a security hole, as someone, who gaines root
somehow (what already is bad eneough) might get more informations of
commands, root did in the past.

You'd like to do without the convenience of a persistent command
history file for root shells.

Since it is your concern to ensure that you don't leave behind shell
command history in a history file:

 1. Did you see Felipe Salvador's suggested addition (elsewhere in
    this thread) to your original workflow? Looked pretty slick to me.

 2. The shell variables HISTFILE and HISTFILESIZE are documented in
    the bash man page. Set HISTFILESIZE to 0, or unset HISTFILE.
    (Since for bash login shells my /root/.profile sources ~/.bashrc,
    my understanding is that it would suffice in my case to set/unset
    these in /root/.bashrc to the appropriate value.)

    If you know you won't want persistent command history on a given
    account, this seems a reasonably reliable way to arrange that you
    don't get one.

 3. Also in the bash man page is documentation of the shell variables
    HISTIGNORE and HISTCONTROL.

     * HISTIGNORE is a colon-separated list of patterns that match
       commands you wish to omit from the history list altogether.

     * HISTCONTROL is a colon-separated list. If one of its elements
       is 'ignorespace', then any command line that begins with a
       space will be omitted from the history list.

    NB: Subsequent lines after the first line, of a multi-line
    command, are stored in the history list regardless of HISTIGNORE
    and HISTCONTROL.

 4. If I remember correctly mksh, the MirBSD Korn shell, by default
    writes to no command history file at all, even for a regular user
    account. (Though this can of course be configured to suit user
    preference.)  Maybe its design would please you better than bash
    in other ways, as well.

As I said, history -c should delete ALL traces of history, just as
the help files tells, shouldn't it?

Just FYI, the documentation on bash builtins you get from "help
[builtin]" is intentionally terse, and provides far less contextual
information, than the information available in the bash man page.

As you confirmed, it does not and you also confirmed, that this is
normal behaviour.

In this case, I recommend this as a failure-by-design.

Again, thanks for your clearence, I will file a bug report.

Of course you will do what seems best to you.

But it seems to me that studying the bash man page, to see what else
you might have wrongly assumed, might make better use of your time.

I base this advice this on two rules of thumb:

 1. Better sooner than later.

 2. The bash man page is dense with useful information.

Good luck with your stuff.

--

"Weʼre not arguing for censorship, weʼre arguing just take it off the
page, put it somewhere else." -- Eric Schmidt

Reply to: