[pacman-dev] Fwd: [PATCH] repo-add: fix eval and quote issues

Sebastian Nowicki sebnow at gmail.com
Mon Feb 16 10:07:36 EST 2009


On 16/02/2009, at 10:57 PM, Dan McGee wrote:

> On Mon, Feb 16, 2009 at 3:32 AM, Sebastian Nowicki  
> <sebnow at gmail.com> wrote:
>>
>> On 16/02/2009, at 5:24 PM, Xavier wrote:
>>
>>> On Mon, Feb 16, 2009 at 4:17 AM, Dan McGee <dpmcgee at gmail.com>  
>>> wrote:
>>>
>>> Wow indeed, I always read the old version wrongly, I just realized  
>>> the
>>> old for was split on two lines :
>>>>
>>>> -       for line in $(bsdtar -xOf "$pkgfile" .PKGINFO | \
>>>> -               grep -v "^#" | sed 's|\(\w*\)\s*=\s*\(.*\)| 
>>>> \1="\2"|'); do
>>
>> How about keeping that part, and just `read`ing the values in:
>>
>> for line in $(bsdtar -xOf "$pkgfile" .PKGINFO | \
>>       grep -v "^#" | sed 's|\(\w*\)\s*=\s*\(.*\)|\1 "\2"|'); do
>>       echo $line | read var val
>>       declare $var="$val"
>>       # Rest is just as in the patch
>> done
>>
>> I haven't actually tested it since the regex is somewhat faulty on  
>> Mac OS X
>> for some reason, and I'm too lazy to boot Arch up :P.
>
> When you do test it, I would put my money on it being broken the same
> way the original one is. :)

*pays up*

Indeed, it's broken. I didn't think that the for loop would be the  
problem. Fortunately this lead to a slightly smaller, albeit less  
legible, loop instead:

$ bsdtar -xOf "$pkgfile" .PKGINFO | grep -v "^#" | sed 's|\(\w*\)\s*= 
\s*\(.*\)|\1 \2|' | while read var val; do echo declare $var=\"$val\";  
done
declare pkgname="perl-bit-vector"
declare pkgver="6.4-3"
declare pkgdesc="Efficient bit vector, set of integers and "big int"  
math library"
declare url="http://search.cpan.org/dist//"
declare builddate="1200021098"
declare packager="Eric Belanger <eric at archlinux.org>"
declare size="463896"
declare arch="x86_64"
declare license="GPL"
declare license="LGPL"
declare license="PerlArtistic"
declare depend="perl-carp-clan"
declare depend="perl>=5.10.0"

Seems to work fine on the package in question.



More information about the pacman-dev mailing list