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).
More Related Contents:
- Make Bash handle variables like Batch
- Some troubles with using sed and awk [closed]
- Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
- Delete all but the most recent X files in bash
- Add a new element to an array without specifying the index in Bash
- How to find the difference in days between two dates?
- Lookup shell variables by name, indirectly [duplicate]
- How to assign a heredoc value to a variable in Bash?
- Command substitution: backticks or dollar sign / paren enclosed? [duplicate]
- How do I use su to execute the rest of the bash script as that user?
- How to iterate over associative arrays in Bash
- How to process each output line in a loop?
- How to extract one column of a csv file
- bash: force exec’d process to have unbuffered stdout
- How do I prevent commands from showing up in Bash history?
- How to include an ‘&’ character in a bash curl statement
- Matching files with various extensions using for loop [duplicate]
- What is the name for `
- How do I echo stars (*) when reading password with `read`?
- Reading key/value parameters from a file into a shell script
- Using dot or “source” while calling another script – what is the difference?
- osascript using bash variable with a space
- Execute command containing quotes from shell variable [duplicate]
- Syntax for a single-line while loop in Bash
- How to use > in an xargs command?
- Unit testing Bash scripts
- How to insert a new line character after a fixed number of characters in a file
- How to add path with space in Bash variable
- Bash If-statement to check If string is equal to one of several string literals [duplicate]
- How to change a command line argument in Bash?