-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: autocomplete panics expanding args when ~/... path is used (#4178)
Signed-off-by: Alex Couture-Beil <[email protected]>
- Loading branch information
Showing
4 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package autocomplete | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
var logPath string | ||
|
||
// SetupLog enables debug-level logging in the autocomplete package when path is set to a logfile. | ||
// this is particuarly useful since autocompletion is called via a shell which can mangle stderr output | ||
// and interprets stdout as autocompletion values. | ||
func SetupLog(path string) { | ||
logPath = path | ||
} | ||
|
||
func Logf(format string, args ...interface{}) { | ||
Log(fmt.Sprintf(format, args...)) | ||
} | ||
|
||
func Log(s string) { | ||
if logPath == "" { | ||
return | ||
} | ||
f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) | ||
if err != nil { | ||
return | ||
} | ||
defer f.Close() | ||
_, _ = f.WriteString(s + "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters