mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-23 22:11:13 +01:00
Add workaround for #69 that avoids go's getCwd method that relies on stat rather than getwd
This commit is contained in:
parent
5089058165
commit
0a694c39d5
@ -53,7 +53,7 @@ var GitCommit string = "Unknown"
|
||||
var maxSupportedLineLengthForImport = 256_000
|
||||
|
||||
func getCwd(ctx *context.Context) (string, string, error) {
|
||||
cwd, err := os.Getwd()
|
||||
cwd, err := getCwdWithoutSubstitution()
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to get cwd for last command: %v", err)
|
||||
}
|
||||
@ -67,6 +67,22 @@ func getCwd(ctx *context.Context) (string, string, error) {
|
||||
return cwd, homedir, nil
|
||||
}
|
||||
|
||||
func getCwdWithoutSubstitution() (string, error) {
|
||||
cwd, err := os.Getwd()
|
||||
if err == nil {
|
||||
return cwd, nil
|
||||
}
|
||||
// Fall back to the syscall to see if that works, as an attempt to
|
||||
// fix github.com/ddworken/hishtory/issues/69
|
||||
if syscall.ImplementsGetwd && false {
|
||||
cwd, err = syscall.Getwd()
|
||||
if err == nil {
|
||||
return cwd, nil
|
||||
}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
func BuildHistoryEntry(ctx *context.Context, args []string) (*data.HistoryEntry, error) {
|
||||
if len(args) < 6 {
|
||||
hctx.GetLogger().Warnf("BuildHistoryEntry called with args=%#v, which has too few entries! This can happen in specific edge cases for newly opened terminals and is likely not a problem.", args)
|
||||
|
Loading…
Reference in New Issue
Block a user