On 01/20/2010 02:49 PM, Loïc Minier wrote:
On Wed, Jan 20, 2010, Paolo Bonzini wrote:
On 01/20/2010 12:37 PM, Loïc Minier wrote:
+ # not found
+ IFS="$local_ifs"
If you do this, you should set IFS to space-tab-lf at the beginning of
the script, like this:
IFS=" "" ""
"
Are you saying that I can't backup/restore IFS without setting it
first?
Yes, it affects the behavior of read for example:
$ echo a b c | (read a b c; echo $a; echo $b; echo $c)
a
b
c
$ IFS=
$ echo a b c | (read a b c; echo $a; echo $b; echo $c)
a b c
$
(It's not used by QEMU's configure, but it's better to be defensive).
or this (better because it does not rely on embedding whitespace
characters within the line):
IFS=`printf ' \t'`"
"
If we go that route, perhaps IFS="`printf ' \t\n'`" would be more
readable? I'm not sure how common printf is though.
I tried that, but backtick strips trailing newlines (or something like
that but anyway it does not work). IFS=`printf ' \n\t'` would work (the
double quotes are not needed) but the Autoconf manual suggests
space-tab-newline in that order (even though only the leading space
seems important from the rest of the paragraph).
printf is fine, though it may not be a builtin. It's actually more
portable (even if slower on some shells) to use printf than echo if you
have variable substitutions in the string, because it handles
consistently the case when the output starts with a minus sign.
Paolo