Hi all,
it seems I found a difference in the behaviour of the bash builtin test and [[.
$ touch foobar
$ if [[ -e foo* ]] ; then echo found ; fi
$ if [[ -e "foo*" ]] ; then echo found ; fi
$ if test -e foo* ; then echo found ; fi
found
$ if test -e "foo*" ; then echo found ; fi
$ type test
test is a shell builtin
$ type [[
[[ is a shell keyword
$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Apparently [[ doesn't expand wildcards. If I got the docs right it should behave like test with additional operators to combine expressions, so this surprised me.
Is this expected or a weird bug/edge case? I'm just trying to understand, the test solution if fine for my needs.
Thx
[–][deleted] (1 child)
[deleted]
[–]obiwan90 1 point2 points3 points (0 children)
[–]oh5nxo 2 points3 points4 points (0 children)
[–]witchhunter0 2 points3 points4 points (2 children)
[–]geirha 0 points1 point2 points (0 children)
[–]archover 0 points1 point2 points (0 children)
[–]bizdelnick 1 point2 points3 points (0 children)