Page 1 of 1

$_ stripped from custom-build command

Posted: Thu Apr 18, 2013 9:56 pm
by plong
How can I prevent the $_ special bash variable from being stripped from a custom-build command? When I use it in this command:

mkdir -p build/usr/bin && cp ../protobuf/linux-z3/usr/bin/protoc $_ && make TARGET=linux-z3

it gets stripped as you can see in this build output:

/bin/sh -c 'mkdir -p build/usr/bin && cp ../protobuf/linux-z3/usr/bin/protoc && make TARGET=linux-z3'
cp: missing destination file operand after `../protobuf/linux-z3/usr/bin/protoc'

If I replace $_ with an explicit path, it works, as in this command:

mkdir -p build/usr/bin && cp ../protobuf/linux-z3/usr/bin/protoc build/usr/bin && make TARGET=linux-z3

BTW, I previously posted http://forums.codelite.org/viewtopic.php?f=11&t=2099, which probably has the same cause--something about the shell CodeLite uses to execute custom build steps.

Re: $_ stripped from custom-build command

Posted: Thu Apr 18, 2013 10:12 pm
by eranif
You can't.
I will add support for escaping the $ sign so codelite will know to skip it...

As a workaround, create a temporary script and run it as the post build comman until this issue is fixed in git head

Eran

Re: $_ stripped from custom-build command

Posted: Thu Apr 18, 2013 10:18 pm
by plong
Wow, cool. Thanks! That was quick. For the time being, I'll avoid using special bash variables and just specify whatever value they represent. They're handy, not essential.

BTW, I tried $$_, thinking that that would escape the $, but that was translated to a lone $. The effect was that protoc was copied to a file named $. :|

Re: $_ stripped from custom-build command

Posted: Thu Apr 18, 2013 10:35 pm
by eranif
BTW, I am currently fixing this by allowing using the regular backslash ("\") for escapring the $ sign
so this will be possible:

Code: Select all

mkdir -p build/usr/bin && cp ../protobuf/linux-z3/usr/bin/protoc \$_ && make TARGET=linux-z3
Eran

Re: $_ stripped from custom-build command

Posted: Thu Apr 18, 2013 11:06 pm
by eranif
EDIT:

This is now fixed in git head, however, to escape the $ sign you need to prepend another $ sign (this is done because some of the commands are executed via Makefile which uses this convention)

So this should work now:

Code: Select all

mkdir -p build/usr/bin && cp ../protobuf/linux-z3/usr/bin/protoc $$_ && make TARGET=linux-z3
Eran

Re: $_ stripped from custom-build command

Posted: Thu Apr 18, 2013 11:09 pm
by plong
Yay! Thanks.