, [[ ... ]] [ ... ] if while, Unix test. , , - test manpage.
Unix /bin/[ /bin/test. Unix :
if test -n $parameter
then
echo "Parameter has a value"
fi
if test $foo = $bar
then
echo "Foo and Bar are equal"
fi
/bin/[, :
if [ -n $parameter ]
then
echo "Parameter has a value"
fi
if [ $foo = $bar ]
then
echo "Foo and Bar are equal"
fi
, .
[[ ... ]] Korn shellism... POSIX-shellism, BASH . , ([[ $foo == bar* ]]) , . :
if [ $foo = $bar ]
, $foo, $bar , :
if [[ $foo = $bar ]]
, .
The syntax [[ ... ]]accepts all the same test parameters as [ ... ], and now it is preferred.
source
share