[Cook] Re: Cook an filenames with ' in them
Peter Miller
millerp at canb.auug.org.au
Mon Feb 18 19:14:57 EST 2008
On Sun, 2008-02-17 at 23:20 +0100, Peder Stray wrote:
> I guess cook doesn't handle filenames with ' (single quote) in them very
> well.
Short answer: use the [quote] function.
Longer explanation, with examples...
I created an example cookbook like this
all: fred;
src = [glob *.c];
obj = [fromto %.c %.o [src]];
fred: [obj]
{
gcc -o [target] [obj];
}
%.o: %.c
{
gcc -O2 -c %.c -o [target];
}
and then I created two source files: main.c and ab'cd.c
this, predictably, had problems...
cook: gcc -O2 -c main.c -o main.o
cook: gcc -O2 -c ab'cd.c -o ab'cd.o
gcc: abcd.c -o abcd.o: No such file or directory
gcc: no input files
cook: command gcc: exit status 1
cook: all: not done because of errors
Cook handles quotes in file names just fine (they are simply strings,
after all), and as you can see it found ab'cd.c and worked out it needed
ab'cd.o just fine. The wheels can off when it needed to run a shell
command with quotes in it.
The [quote] function (see the user manual) was designed for just this
purpose. Cook doesn't automagically quote everything, because there are
equally valid times when you *don't* want things quoted. So its up to
the cookbook writer to say what they mean.
If strategic portions of the cookbook employ the [quote] function, like
this
all: fred;
src = [glob *.c];
obj = [fromto %.c %.o [src]];
fred: [obj]
{
gcc -o [quote [target]] [quote [obj]];
}
%.o: %.c
{
gcc -O2 -c [quote %.c] -o [quote [target]];
}
then everything works as expected
cook: gcc -O2 -c main.c -o main.o
cook: gcc -O2 -c "ab'cd.c" -o "ab'cd.o"
cook: gcc -o fred "ab'cd.o" main.o
hope this helps
Regards
Peter Miller <millerp at canb.auug.org.au>
/\/\* http://miller.emu.id.au/pmiller/
PGP public key ID: 1024D/D0EDB64D
fingerprint = AD0A C5DF C426 4F03 5D53 2BDB 18D8 A4E2 D0ED B64D
See http://www.keyserver.net or any PGP keyserver for public key.
"Debian: The community version of Ubuntu"
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20080218/401ca882/attachment.pgp>
More information about the Cook-users
mailing list