First of all, use shell debug option
set -vx to see how/when vars, etc. are being evaluated.
Sorry, but why do you have your code setup like
because going to later use the variable
If so, then you almost certainly need to do
which is opening up a whole new can of worms as far as escaping special characters. As another commentor points out you'll not just have to escape the required characters, you'll have to doubly escape them. When I used to get things like this to work, I could wind up with escapes like
\\\\\ (5!) to get things working.
Without further explanation of the context for this code, my recommendation is to leave out the
run= stuff and just run
tail -n0 -f -s 0.01 $cmds |.... as is.
Also, per Gilles comment, and to amplify on it, your whole pipe-line doesn't make much sense,
tail -n0 -f -s 0.01 $cmds | (while true; do $tron ....
A. we don't know what is in
B. There is nothing I can see inside the sub-shell
(while true; ...) that is reading the output of the tail cmd. If you say it is passed complete into the subsequent
tee after end of the
while , then I've learned something new.
C. Do you really want to execute $tron command as fast as you can in an infinite loop? On a lot of systems, this will wind up consuming at least 1 CPUs full capacity. Maybe add a
Adding more context about what you're trying to accomplish will help us help you! Good luck.