LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 02-05-2019, 08:30 AM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
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
 
Old 02-05-2019, 08:45 AM   #2
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
^ 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?
 
Old 02-05-2019, 12:03 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,729

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
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.
 
Old 02-05-2019, 02:23 PM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 02-05-2019, 02:26 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
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.
 
Old 02-05-2019, 02:45 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by pan64 View Post
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.
 
Old 02-05-2019, 08:49 PM   #7
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Original Poster
Rep: Reputation: 15
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

Last edited by BudiKusasi; 02-06-2019 at 03:14 AM.
 
Old 02-06-2019, 03:15 AM   #8
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
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...
 
Old 02-06-2019, 12:53 PM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent shell script from being run directly using sh command shazgaurav Linux - Newbie 4 06-28-2016 02:56 AM
Why does BASH history command have no history when run in script ? lump_of_lard Programming 4 01-30-2015 09:45 AM
[SOLVED] History utility error in Linux Mint 14; cannot delete history mintyninja41 Linux - Newbie 3 03-22-2013 06:36 AM
Can't open saved web pages just saved by web browser... JeanBrownHarrel General 2 04-06-2008 11:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration