Skip to content

great starting point, but found a few issues #8

Description

@brandon1024

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions