vendredi 10 mars 2017

bash negation of a regular expresson

I am trying to make a bash program that saves results to a file with the name of the user's choosing if the program is supplied the --file argument followed by an option, in which the option should not start with a dash. So I used the following conditional:

    if [[ -n $2 && !($2="[^-]") ]]

But that didn't work. It still saves the output to a file even if the second argument starts with a dash. I also tried using this:

   1) if ! [[ -z $2 && ($2="[^-]") ]]

It also did as the previous one. What's the problem? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire