diff options
| author | Jeff Carr <[email protected]> | 2025-10-28 22:26:32 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-28 22:26:32 -0500 |
| commit | d1c6c000ccedf21e356ee30411b861b544313e18 (patch) | |
| tree | 753ad517e06cea3e16b6ea2fcdc2794075915456 | |
| parent | 816758895ca1244c967817565b5d9895857e1cbb (diff) | |
remove panic's
| -rw-r--r-- | argv.Print.go | 22 | ||||
| -rw-r--r-- | theMagicOfAutocomplete.go | 5 |
2 files changed, 25 insertions, 2 deletions
diff --git a/argv.Print.go b/argv.Print.go index 68c2391..a35d380 100644 --- a/argv.Print.go +++ b/argv.Print.go @@ -9,6 +9,7 @@ import ( "strings" "go.wit.com/lib/cobol" + "go.wit.com/lib/config" ) func (pb *Argv) Debugf(fmts string, parts ...any) { @@ -67,9 +68,28 @@ func PrintStddbg() { if !me.debug { return } + if config.Exists("/tmp/argv.debug") { + PrintStddbgFile() + return + } + lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") + if len(lines) == 0 { + return + } + fmt.Fprintf(os.Stderr, "\n") + for _, line := range lines { + fmt.Fprintf(os.Stderr, "%s\n", line) + } + fmt.Fprintf(os.Stderr, "\n") +} + +func PrintStddbgFile() { + if !me.debug { + return + } f, err := os.OpenFile("/tmp/argv.debug", os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644) if err != nil { - panic("WTF openfile") + return } defer f.Close() lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index 95585bd..e8a63ff 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -171,8 +171,11 @@ func examineArgvHistory() { // me.debug = true me.pb.Stddbg += fmt.Sprintf("config.CreateCacheDirPB() err(%v)\n", me.Err) + me.pb.Stddbg += fmt.Sprintf("argvpb.Load() history file failed") PrintStderr() - panic("argvpb.Load() history file failed") + me.all = NewArgvs() + me.debug = true + return } if me.debug { // use this if you are having trouble debugging this code |
