There are 3 files (a
, b
and c
), all with 777
permissions:
$ ls
a b c
The above files have the following contents:
$ cat a
#!/bin/bash
export A=aaa
$ cat b
#!/bin/bash
source ./a
echo $A
$ cat c
#!/bin/bash
source ./a | >> log
echo $A
The only difference between b
and c
is | >> log
:
$ diff b c
2c2
< source ./a
---
> source ./a | >> log
When b
is executed it outputs the expected aaa
:
$ ./b
aaa
When c
is executed it outputs, for me, an unexpected blank row instead of the expected aaa
, and the log
file that script c
created is empty:
$ ./c
$ cat log
$
Clearly, there is something about source
and |
that I have yet to learn.
Could someone please enlighten me regarding why c
does not output aaa
?