diff --git a/cmd/ttg/main.go b/cmd/ttg/main.go index 6553a4d..6ff06cd 100644 --- a/cmd/ttg/main.go +++ b/cmd/ttg/main.go @@ -70,9 +70,11 @@ func main() { } if outFile != "" { - if err := file.WriteAndExit(outFile, entries[selected]); err != nil { + if err := file.Write(outFile, entries[selected]); err != nil { log.Fatalf("failed to write output file: %s", err.Error()) } + + os.Exit(0) } shell.Spawn(entries[selected]) diff --git a/pkg/file/file.go b/pkg/file/file.go index d429e2d..256a4a5 100644 --- a/pkg/file/file.go +++ b/pkg/file/file.go @@ -4,12 +4,8 @@ import ( "os" ) -func WriteAndExit(outFile string, path string) error { +func Write(outFile string, path string) error { err := os.WriteFile(outFile, []byte(path), 0644) - if err == nil { - os.Exit(0) - } - return err }