@@ -31,24 +31,38 @@ def clearHistory():
3131
3232 readline .clear_history ()
3333
34- def saveHistory ():
34+ def saveHistory (completion = None ):
3535 if not readlineAvailable ():
3636 return
3737
38- historyPath = os .path .expanduser (paths .SQLMAP_SHELL_HISTORY )
38+ if completion == AUTOCOMPLETE_TYPE .SQL :
39+ historyPath = paths .SQL_SHELL_HISTORY
40+ elif completion == AUTOCOMPLETE_TYPE .OS :
41+ historyPath = paths .OS_SHELL_HISTORY
42+ else :
43+ historyPath = paths .SQLMAP_SHELL_HISTORY
44+
3945 try :
40- os .remove (historyPath )
46+ with open (historyPath , "rw+" ) as f :
47+ f .truncate ()
4148 except :
4249 pass
4350
4451 readline .set_history_length (MAX_HISTORY_LENGTH )
4552 readline .write_history_file (historyPath )
4653
47- def loadHistory ():
54+ def loadHistory (completion = None ):
4855 if not readlineAvailable ():
4956 return
5057
51- historyPath = os .path .expanduser (paths .SQLMAP_SHELL_HISTORY )
58+ clearHistory ()
59+
60+ if completion == AUTOCOMPLETE_TYPE .SQL :
61+ historyPath = paths .SQL_SHELL_HISTORY
62+ elif completion == AUTOCOMPLETE_TYPE .OS :
63+ historyPath = paths .OS_SHELL_HISTORY
64+ else :
65+ historyPath = paths .SQLMAP_SHELL_HISTORY
5266
5367 if os .path .exists (historyPath ):
5468 try :
@@ -107,5 +121,5 @@ def autoCompletion(completion=None, os=None, commands=None):
107121 readline .set_completer (completer .complete )
108122 readline .parse_and_bind ("tab: complete" )
109123
110- loadHistory ()
111- atexit .register (saveHistory )
124+ loadHistory (completion )
125+ atexit .register (saveHistory , completion )
0 commit comments