LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How to prevent error shell command input from being ignored to be saved in history (https://www.linuxquestions.org/questions/linux-desktop-74/how-to-prevent-error-shell-command-input-from-being-ignored-to-be-saved-in-history-4175647654/)

BudiKusasi 02-05-2019 08:30 AM

How to prevent error shell command input from being ignored to be saved in history
 
How to prevent error/unrecognized shell command input on mintty/xterm terminal from being discarded or ignored to be saved in history? instead it needs to be saved like another else

l0f4r0 02-05-2019 08:45 AM

^ I'm not sure history is a terminal functionality. I can be wrong but I would say it is handled by the shell directly.
Let me rephrase your sentence please to be sure: currently, wrong commands or commands giving errors in output are not properly loggued in your command history, aren't they?

scasey 02-05-2019 12:03 PM

I agree. history is a shell function...and in my experience, all command line input is saved there...even boo-boos.

I think we need a better description of the OPs problem.

ondoho 02-05-2019 02:23 PM

fwiw, i have experienced what op describes.
i'm not exactly sure how my shell (bash) handles this; triggering a command not found error or simply entering "false" is not enough.

pan64 02-05-2019 02:26 PM

not enough for what?
What I know if the command line started with a space it won't be saved, but that is a different issue.

ondoho 02-05-2019 02:45 PM

Quote:

Originally Posted by pan64 (Post 5958143)
not enough for what?

for it to not be recallable with the Up arrow key.
Quote:

What I know if the command line started with a space it won't be saved, but that is a different issue.
that is a different issue.

i know, it's vague.
just wanted to give op a +1.
i'll try to remember this thread when i stumble upon it.

BudiKusasi 02-05-2019 08:49 PM

Yeah I'm myself confused, only in rare occasion is not saved as command failed, but that when I really needed.. just pissed me off

l0f4r0 02-06-2019 03:15 AM

How do you know it's not been saved? I mean did you check with history/! command, with up/down keys or did you dig into ~/.<your_shell>_history file?
Sometimes there can be differences if the latter has not been correctly/yet written...

ondoho 02-06-2019 12:53 PM

here's one way it can happen:
  • type something into the command line, do not enter
  • ctrl-c
  • you get a new command line
  • what you typed cannot be accessed with arrow keys, it's not in history
that's a very stupid and obvious example, but it has happened in other situations too. maybe those were less obvious variations on the example i just gave...


All times are GMT -5. The time now is 11:52 PM.