这是bash中的一个错误吗?(向上箭头)

时间:2012-04-01 01:49:23

标签: linux bash

如我们所知,按向上箭头键可以显示历史命令,但我发现当以空格开头的命令不会显示在“向上箭头”的历史记录中时:

$ls

$(press up arrow key)

bash将显示:

$ls

但是:

$ps

$ ls(notice this command starts with a space)

现在我按向上箭头键,它会显示'ps'而不是'ls':

$ps

这是bash或特定功能中的错误吗?:)

1 个答案:

答案 0 :(得分:12)

来自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.

这是一项有意的功能,可以防止将带有密码或其他私人数据的命令保存到磁盘。 (它不会将其排除在ps(1)流程列表之外。)