Calling wait without an argument waits for all background jobs. The separate - tells the set command that there are no more options, and all following words are arguments. Some options are simple flags. One should be able to give options in any order. Each arm of the case statement consumes exactly the elements of the argument that it has processed.
Some shell scripts use temporary files.
Such scripts should ensure that these get cleaned up on exit and if the shell script is interrupted. After you execute set -x, sh will print each command just before it is executed. This is useful for tracing control flow problems. After you execute set -v, sh will print each command just after it has been read in. This is useful for tracing syntax problems such as a missing fi or done, and missing or extra quotation marks.