@@ -104,6 +104,13 @@ func run(ctx context.Context, args []string) error {
104104}
105105
106106func runCopy (ctx context.Context , sources []string , dest string ) error {
107+ if ! term .IsTerminal (os .Stdout .Fd ()) {
108+ return runCopyDirect (sources , dest )
109+ }
110+ if w , _ , err := term .GetSize (os .Stdout .Fd ()); err != nil || w == 0 {
111+ return runCopyDirect (sources , dest )
112+ }
113+
107114 stats , err := walk .ComputeStats (sources )
108115 if err != nil {
109116 return err
@@ -143,7 +150,9 @@ func runCopyWithProgress(ctx context.Context, sources []string, dest string, sta
143150 model := ui .NewModel (ui .ThemeMocha , ui .OpCopy , flagVerbose , stats .TotalBytes , stats .TotalFiles )
144151 p := tea .NewProgram (model )
145152
153+ done := make (chan struct {})
146154 go func () {
155+ defer close (done )
147156 var cumulBytes , cumulFiles int64
148157 for _ , src := range sources {
149158 dst := destPath (dest , src )
@@ -162,8 +171,10 @@ func runCopyWithProgress(ctx context.Context, sources []string, dest string, sta
162171 }()
163172
164173 if _ , err := p .Run (); err != nil {
165- return runCopyDirect (sources , dest )
174+ <- done
175+ return summarizeErrors (ec )
166176 }
177+ <- done
167178
168179 if ctx .Err () != nil {
169180 printInterrupted ("copy" , stats .TotalFiles )
0 commit comments