|
@@ -13,8 +13,13 @@ func main() {
|
|
|
scanner := bufio.NewScanner(histfile)
|
|
scanner := bufio.NewScanner(histfile)
|
|
|
var i = 0
|
|
var i = 0
|
|
|
for scanner.Scan() {
|
|
for scanner.Scan() {
|
|
|
- history[strings.TrimSpace(scanner.Text())] = i
|
|
|
|
|
- i++
|
|
|
|
|
|
|
+ line := strings.TrimSpace(scanner.Text())
|
|
|
|
|
+ if len(line) > 0 {
|
|
|
|
|
+ if history[line] == 0 {
|
|
|
|
|
+ history[line] = i
|
|
|
|
|
+ i++
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
defer histfile.Close()
|
|
defer histfile.Close()
|
|
@@ -27,9 +32,7 @@ func main() {
|
|
|
newhistfile, _ := os.OpenFile(mktmpfile(), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
|
|
newhistfile, _ := os.OpenFile(mktmpfile(), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
|
|
|
newhistfile.Truncate(0)
|
|
newhistfile.Truncate(0)
|
|
|
for _, key := range ah {
|
|
for _, key := range ah {
|
|
|
- if len(strings.TrimSpace(key)) > 0 {
|
|
|
|
|
- newhistfile.WriteString(key + "\n")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ newhistfile.WriteString(key + "\n")
|
|
|
}
|
|
}
|
|
|
newhistfile.Sync()
|
|
newhistfile.Sync()
|
|
|
CopyFile(mktmpfile(), gethistfile())
|
|
CopyFile(mktmpfile(), gethistfile())
|