2017-05-08 95 views
1

中的.bashrc猛砸歷史範圍

function gitpullsite(){ 
    echo "Enter GIT username"; 
    read gituname; 
    echo "Enter GIT password"; 
    read -s gitpword; 
    giturl=https://$gituname:[email protected]/whateveruser/whateverrepo.git 
    repopath=/home/whateveruser/html/whateverrepo/; 
    sudo rm -r $repopath; 
    sudo git clone $giturl $repopath; 
} 

定義,然後在終端gitpullsite我想刪除從歷史gitunamegitpword運行,但在歷史上,我不能找到這樣的條目的任何地方。我沒有適當的流程去除這些條目,因此這個歷史存儲在哪裏?它是否在功能範圍內而不是shell被忽略?

我不想要的是一個未知的用戶名和密碼蹤跡,存儲在我不知道的地方 - 一個明顯的安全問題應該是系統受到危害。

目標是添加更多不同的'嵌套'回購,但用戶只需輸入憑證一次。

+2

我不知道我理解你的問題,但在bash歷史通常會被保存在'〜/ .bash_history'。它只會保存命令,而不是響應'read'的輸入。 – 0range

+0

是的,這是我試圖確認,一個函數內的命令不存儲,只是對該函數的調用 - 不幸的是我不允許標記'.bash_history' – Datadimension

+1

不僅不會保存密碼,它實際上只會保存直接發出的命令,即'gitpullsite'。 – 0range

回答

0

您可能想嘗試https://github.com/dvorka/hstr,除了歷史管理,即從歷史刪除特定命令的,允許「建議箱式」過濾。

enter image description here

它可以很容易地boundCTRL-R和/或按Ctrl-S

0

一個可能的解決辦法是無法登錄你的命令的一部分,在所有。

多種方式這樣做:

停止記錄bash的歷史是:

set +o history 

和復位,也就是重新開始記錄:

set -o history 

您也可以使用add ignoresp ace添加到您的HISTCONTROL環境變量中。然後任何以空格開頭的命令行都不會輸入到您的歷史記錄中。

methods for avoiding bash history logging

Can you prevent a command from going into the bash shell command history?