Unverified Commit d88972ea authored by Daniel Hiltgen's avatar Daniel Hiltgen Committed by GitHub
Browse files

Be quiet when redirecting output (#7360)

This avoids emitting the progress indicators to stderr, and the interactive
prompts to the output file or pipe.  Running "ollama run model > out.txt"
now exits immediately, and "echo hello | ollama run model > out.txt"
produces zero stderr output and a typical response in out.txt
parent 25c9339e
...@@ -456,6 +456,10 @@ func RunHandler(cmd *cobra.Command, args []string) error { ...@@ -456,6 +456,10 @@ func RunHandler(cmd *cobra.Command, args []string) error {
if len(prompts) > 0 { if len(prompts) > 0 {
interactive = false interactive = false
} }
// Be quiet if we're redirecting to a pipe or file
if !term.IsTerminal(int(os.Stdout.Fd())) {
interactive = false
}
nowrap, err := cmd.Flags().GetBool("nowordwrap") nowrap, err := cmd.Flags().GetBool("nowordwrap")
if err != nil { if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment