1

I'm seeing an odd issue with CentOS 6.4, zsh 4.3.10 (x86_64-redhat-linux-gnu).

This is running two regular expressions on the same string. Neither expression passes the if conditional, but when I OR them together

$ if [[ "foo" =~ "^\s*$" ]]; then; echo "Test"; fi
$ if [[ "foo" =~ "^\.+$" ]]; then; echo "Test"; fi
$ if [[ "foo" =~ "^\.+$" || "foo" =~ "^\s*$" ]]; then; echo "OR test"; fi
OR test

This only happens on CentOS as far as I can tell, I get expected behavior with zsh 5.0.2 (x86_64-apple-darwin13.0) and zsh 5.0.2 (x86_64-pc-linux-gnu)

1

Last if should be slightly different if or is desired. Try:

if [[ "foo" =~ "^\.+$" ]] || [[ "foo" =~ "^\s*$" ]]; then; echo "OR test"; fi

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.