I am getting some strange behavior when piping the output of a function to the tee
command. The first problem is that I can't exit the program when using the exit
command when called from a function piped to tee
. For Example:
myfunction(){
# Some stuff here
exit 1
}
myfunction | tee -a $UPGRADE_LOG
When I run the above code, the program fails to exit and runs to completion.
The other issue I am having is that tee
seems to have cause some code to run in such a way that the sequential order is undone. I have the following output:
SHOWING SYSTEM-WIDE AND INSTATNCE MEMORY USAGE:
Are you sure you would like to back up the instance given current memory contraints? [y/n]: Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root 15G 13G 1.5G 90% /
Log File Size: 24K Total Size to Package: 248K Available Space: 1.5G
When it should run as:
SHOWING SYSTEM-WIDE AND INSTATNCE MEMORY USAGE:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root 15G 13G 1.5G 90% /
Log File Size: 24K Total Size to Package: 248K Available Space: 1.5G
Are you sure you would like to back up the instance given current memory contraints? [y/n]:
Things work properly when not using tee
. The issues seem to be related to one another. Any ideas why this is the case and what I should do about it?