History adjustments
This commit is contained in:
parent
d7933a244a
commit
e0cb7c11b3
@ -25,11 +25,18 @@ var (
|
|||||||
extraDebug = false
|
extraDebug = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var noHist = map[string]bool{"clear": true, "exit": true, "quit": true}
|
||||||
|
|
||||||
// Interpret is where we will actuall define our Commands
|
// Interpret is where we will actuall define our Commands
|
||||||
func executor(cmd string) {
|
func executor(cmd string) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.Error().Msgf("PANIC: %s", r)
|
||||||
|
}
|
||||||
|
if _, ok := noHist[cmd]; !ok {
|
||||||
history = append(history, cmd)
|
history = append(history, cmd)
|
||||||
saveHist()
|
go saveHist()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
cmd = strings.TrimSpace(cmd)
|
cmd = strings.TrimSpace(cmd)
|
||||||
var args = strings.Fields(cmd)
|
var args = strings.Fields(cmd)
|
||||||
@ -163,8 +170,10 @@ func getHist() []string {
|
|||||||
rb, _ := os.OpenFile(filepath.Join(pth, ".ziggs_history"), os.O_RDONLY, 0644)
|
rb, _ := os.OpenFile(filepath.Join(pth, ".ziggs_history"), os.O_RDONLY, 0644)
|
||||||
xerox := bufio.NewScanner(rb)
|
xerox := bufio.NewScanner(rb)
|
||||||
for xerox.Scan() {
|
for xerox.Scan() {
|
||||||
|
if strings.TrimSpace(xerox.Text()) != "" {
|
||||||
history = append(history, xerox.Text())
|
history = append(history, xerox.Text())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
histLoaded = true
|
histLoaded = true
|
||||||
}
|
}
|
||||||
return history
|
return history
|
||||||
|
Loading…
Reference in New Issue
Block a user