In bash tee is making function variables local, how do I escape this?
问题 I have stucked with a bash scipt which should write both to stdout and into file. I'm using functions and some variables inside them. Whenever I try to redirect the function to a file and print on the screen with tee I can't use the variables that I used in function, so they become local somehow. Here is simple example: #!/bin/bash LOGV=/root/log function var() { echo -e "Please, insert VAR value:\n" read -re VAR } var 2>&1 | tee $LOGV echo "This is VAR:$VAR" Output: [root@testbox ~]# ./var