Skip to content

Commit 070ae5c

Browse files
committed
fix nits
1 parent 45818ef commit 070ae5c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

cmd/server/main-server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ func main() {
465465
return
466466
}
467467

468-
shellutil.FixupWaveZshHistory()
468+
err = shellutil.FixupWaveZshHistory()
469+
if err != nil {
470+
log.Printf("error fixing up wave zsh history: %v\n", err)
471+
}
469472
createMainWshClient()
470473
sigutil.InstallShutdownSignalHandlers(doShutdown)
471474
sigutil.InstallSIGUSR1Handler()

pkg/util/shellutil/shellutil.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ var (
4747

4848
//go:embed shellintegration/pwsh_wavepwsh.sh
4949
PwshStartup_wavepwsh string
50+
51+
ZshExtendedHistoryPattern = regexp.MustCompile(`^: [0-9]+:`)
5052
)
5153

5254
const DefaultTermType = "xterm-256color"
@@ -238,13 +240,12 @@ func IsExtendedZshHistoryFile(fileName string) (bool, error) {
238240
content := string(buf[:n])
239241
lines := strings.Split(content, "\n")
240242

241-
extendedPattern := regexp.MustCompile(`^: [0-9]+:`)
242243
for _, line := range lines {
243244
line = strings.TrimSpace(line)
244245
if line == "" {
245246
continue
246247
}
247-
return extendedPattern.MatchString(line), nil
248+
return ZshExtendedHistoryPattern.MatchString(line), nil
248249
}
249250

250251
return false, nil
@@ -478,7 +479,10 @@ func FixupWaveZshHistory() error {
478479
waveHistFile := filepath.Join(zshDir, ZshHistoryFileName)
479480

480481
if size == 0 {
481-
os.Remove(waveHistFile)
482+
err := os.Remove(waveHistFile)
483+
if err != nil {
484+
log.Printf("error removing wave zsh history file %s: %v\n", waveHistFile, err)
485+
}
482486
return nil
483487
}
484488

@@ -521,7 +525,10 @@ func FixupWaveZshHistory() error {
521525
return fmt.Errorf("error executing zsh history fixup script: %w, output: %s", err, string(output))
522526
}
523527

524-
os.Remove(waveHistFile)
528+
err = os.Remove(waveHistFile)
529+
if err != nil {
530+
log.Printf("error removing wave zsh history file %s: %v\n", waveHistFile, err)
531+
}
525532
log.Printf("successfully merged wave zsh history %s into ~/.zsh_history\n", waveHistFile)
526533

527534
return nil

0 commit comments

Comments
 (0)