$_ stripped from custom-build command

General questions regarding the usage of CodeLite
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

$_ stripped from custom-build command

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: $_ stripped from custom-build command

Post 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
Make sure you have read the HOW TO POST thread
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: $_ stripped from custom-build command

Post 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 $. :|
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: $_ stripped from custom-build command

Post 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
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: $_ stripped from custom-build command

Post 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
Make sure you have read the HOW TO POST thread
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: $_ stripped from custom-build command

Post by plong »

Yay! Thanks.
Post Reply