mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-12 08:19:29 +02:00
For some reason macos includes N at the end of ints, fix this
This commit is contained in:
@ -85,7 +85,7 @@ func BuildHistoryEntry(args []string) (*data.HistoryEntry, error) {
|
||||
entry.CurrentWorkingDirectory = cwd
|
||||
|
||||
// start time
|
||||
nanos, err := strconv.ParseInt(args[4], 10, 64)
|
||||
nanos, err := parseCrossPlatformInt(args[4])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse start time %s as int: %v", args[4], err)
|
||||
}
|
||||
@ -122,6 +122,11 @@ func BuildHistoryEntry(args []string) (*data.HistoryEntry, error) {
|
||||
return &entry, nil
|
||||
}
|
||||
|
||||
func parseCrossPlatformInt(data string) (int64, error) {
|
||||
data = strings.TrimSuffix(data, "N")
|
||||
return strconv.ParseInt(data, 10, 64)
|
||||
}
|
||||
|
||||
func getLastCommand(history string) (string, error) {
|
||||
return strings.SplitN(strings.TrimSpace(history), " ", 2)[1][1:], nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user