From 06590601f0d8f049b6de1304505e06ed411cb1f8 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Tue, 27 Sep 2022 22:30:35 -0700 Subject: [PATCH] Add fix for bash weirdness introduced by the previous commit --- client/lib/lib.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/lib/lib.go b/client/lib/lib.go index 285f0c8..714d073 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -165,6 +165,13 @@ func isZshWeirdness(cmd string) bool { return len(matches) == 2 } +func isBashWeirdness(cmd string) bool { + // Bash has this weird behavior where the it has entries like `#1664342754` in the + // history file. We want to skip these. + firstCommandBugRegex := regexp.MustCompile(`#\d+`) + return firstCommandBugRegex.MatchString(cmd) +} + func buildRegexFromTimeFormat(timeFormat string) string { expectedRegex := "" lastCharWasPercent := false @@ -410,7 +417,7 @@ func ImportHistory(ctx *context.Context) (int, error) { return 0, err } for _, cmd := range historyEntries { - if isZshWeirdness(cmd) { + if isZshWeirdness(cmd) || isBashWeirdness(cmd) { // Skip it continue }