Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a bug in bash ?(up arrow)

Tags:

linux

bash

As we know, press up arrow key can show history commands,but i found that when a command which starting with space will not show in "up arrow"'s history:

$ls

$(press up arrow key)

bash will show:

$ls

however:

$ps

$ ls(notice this command starts with a space)

now i press up arrow key,it will show 'ps' but not 'ls':

$ps

Is this a bug in bash or a specific feature?:)

like image 761
Coaku Avatar asked Feb 03 '23 06:02

Coaku


1 Answers

From bash(1):

   HISTCONTROL
          A colon-separated list of values controlling how
          commands are saved on the history list.  If the list
          of values includes ignorespace, lines which begin with
          a space character are not saved in the history list.

It's an intentional feature to let you prevent commands with passwords or other private data from being saved to disk. (It won't keep it out of the ps(1) process listing.)

like image 105
sarnold Avatar answered Feb 05 '23 16:02

sarnold