Reputation: 2287
I read a code which is written by another person in bash. It includes the following code,
[[ ${variable} ]]
It seems it works as
[[ -n ${variable} ]]
Is it correct?
Upvotes: 2
Views: 85
Reputation: 42087
Yes, without any option inside [[
([[
is a bash
keyword though), the behavior is exactly same to using the -n
option i.e. it is checking if the string is non-empty (i.e. length > 0), and gives exit status 0
if the string is not empty as you can imagine.
Upvotes: 3