bash-spinner icon indicating copy to clipboard operation
bash-spinner copied to clipboard

great starting point, but found a few issues

Open brandon1024 opened this issue 2 years ago • 0 comments

Thanks! This script inspired me to build a progress spinner for some scripts I'm writing.

I have found a few issues though:

  • if stop_spinner is called immediately after start_spinner (or some operation completes very quickly), the output gets a bit messed up. This is because stop_spinner doesn't wait for the spinner job to terminate before writing to the terminal. This can be accomplished with a simple wait ${_sp_pid}.
  • all messages are written to stdout, where stderr is usually meant for these sorts of applications. Stdout is a buffered stream, and stderr is not, so stderr will actually work a bit better (less flickering).
  • the script doesn't detect if the output (or error) stream is a terminal. It's probably undesirable to print progress information if the script output is being redirected to a file or another process. You could fix this with a simple [[ ! -t 1 ]] check.

brandon1024 avatar May 13 '22 12:05 brandon1024