You seem to be confused bash
with another programming language. The variables are replaced, then what is left is executed.
"$a"
This is the contents a
, between quotation marks. a
is empty, so this is equivalent to:
""
. " ." , ( 0), - && echo 1
- .
...
``
... , , , . ( $()
, script.) ...
`echo "foo"`
... ...
foo
..., . , ...
``
... ...
<empty>
... " " ( ).
a
echo 1
, a
, test
:
test -n "$a" && echo 1
test
, [
, ]
...
[ -n "$a" ] && echo 1
... bash -ism [[
, "" , , , , $a
...
[[ -n $a ]] && echo 1
... , , ...
if [[ -n $a ]]
then
echo 1
fi
. :
$a && echo 1
, &&
. , . bash :
$a
...
<empty>
... "", . ...
&& echo 1
... , .;-) (Tricky, , , cookie .)