Hello,
could anyone please explain why variable DIR1 disappears in script2 (when functions f1/f2 are "piped" to tee command)?
Code:
# cat ddd
#!/usr/bin/ksh
f1 () {
DIR1=/mnt/swt
echo inside f1 DIR1 is ${DIR1}
}
f2 () {
echo inside f2 DIR1 is ${DIR1}
}
f1
echo outside f1 DIR1 is $DIR1
f2
# ./ddd
inside f1 DIR1 is /mnt/swt
outside f1 DIR1 is /mnt/swt
inside f2 DIR1 is /mnt/swt
#
Code:
# cat ddd
#!/usr/bin/ksh
f1 () {
DIR1=/mnt/swt
echo inside f1 DIR1 is ${DIR1}
}
f2 () {
echo inside f2 DIR1 is ${DIR1}
}
f1 | tee -a /tmp/log1
echo outside f1 DIR1 is $DIR1
f2 | tee -a /tmp/log1
# ./ddd
inside f1 DIR1 is /mnt/swt
outside f1 DIR1 is
inside f2 DIR1 is
#