|
From: | Paolo Bonzini |
Subject: | [Qemu-devel] Re: Stop using "which" in ./configure |
Date: | Wed, 20 Jan 2010 15:18:53 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |