Consider this...
#!/bin/bash
declare STR='test'
declare SUB=''
[[ "${STR}" == *"${SUB}"* ]] && echo 'match'
This appears to resolve or evaluate to true? This makes no sense to me.
To get the expected result you have to test if the SUB string is empty?
#!/bin/bash
declare STR='test'
declare SUB=''
[[ ! -z "${SUB}" ]] && [[ "${STR}" == *"${SUB}"* ]] && echo 'match'
Is this some quirk with BASH or such? If the sub string is NOT in the string should it not return false?
[[ foo = * ]]be different from[[ foo = *'' ]]or[[ foo = *''* ]]or[[ foo = ''* ]]?'' in 'foo'is true. So is'foo'.endswith(''), and'foo'.startswith('').*"${SUB}"*is exactly identical to**, which is semantically the same as*(although with multiple different ways to match).*"${SUB}"*Why did you put asterisks?[[ 'whatever' == * ]]will always match! Not an odd behavior at all... whenSUB=''is left blank it will match, whenSUB='foo'has "some other" value it will NOT match.strstr()function.