Hello,
I wrote a simple script that takes either two or three parameters, or '-h' or '--help' to show a friendly usage string. My test for this is as follows:
It works correctly if I use two or three parameters or if the first parameter is '-h', but not if the first parameter is '--help'. Oddly enough, though, it displays the help message if the second parameter is '--help'. For testing purposes I am echoing "$0 $1 $2 $3" and that shows that '--help' is indeed $1 but it still fails the test. Anybody know what is going on here?
I wrote a simple script that takes either two or three parameters, or '-h' or '--help' to show a friendly usage string. My test for this is as follows:
Code:
if [[ ! -z $2 || $1 -eq "-h" || $1 -eq "--help" ]]
It works correctly if I use two or three parameters or if the first parameter is '-h', but not if the first parameter is '--help'. Oddly enough, though, it displays the help message if the second parameter is '--help'. For testing purposes I am echoing "$0 $1 $2 $3" and that shows that '--help' is indeed $1 but it still fails the test. Anybody know what is going on here?