Quotes!
if [ "$1" != -v ]; then
Otherwise, when $1 is completely empty, your test becomes:
[ != -v ]
instead of
[ "" != -v ]
…and != is not a unary operator (that is, one capable of taking only a single argument).
Quotes!
if [ "$1" != -v ]; then
Otherwise, when $1 is completely empty, your test becomes:
[ != -v ]
instead of
[ "" != -v ]
…and != is not a unary operator (that is, one capable of taking only a single argument).