Do you know what the solution is? I've tried the 'set' command, but this doesn't seem to behave according standard ash set (according to the 'set' manpage)
On 05/25/2011 10:24 AM, Nigel Hathaway wrote: > I'm trying to import a set of variables from a file containing assignments of > the form "a=b", one on each line. I am finding that the variable assignments > are being lost. > > Here is a simplified version of my script which illustrates the problem: > > echo "myvar=my value" | while read opt; do > if echo "$opt" | grep -q '='; then > var=`echo "$opt" | /bin/sed "s/=.*//"` > val=`echo "$opt" | /bin/sed "s/[^=]*=//"` > eval $var=\'$val\' > echo "(1)" $var=\'$val\' > echo "(2) myvar=$myvar" > fi > done > echo "(3) myvar=$myvar" > > Which yields this: > > (1) myvar='my value' > (2) myvar=my value > (3) myvar= > > I am using Busybox v1.18.4 > > Any idea what is going on? Hi Nigel, You will get the same results if you run that logic through bash. The problem is that your eval logic only has effect until the loop (everything after the pipe '|') ends. Run it in bash and you will see the same thing. Chuck _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox