hlnd / nrf51-pure-gcc-setup

A simple and cross-platform GCC setup for nRF51-series development for Windows, OS X and Linux
BSD 3-Clause "New" or "Revised" License
131 stars 36 forks source link

Bash character expansion #2

Closed fredericmorin closed 10 years ago

fredericmorin commented 10 years ago

I hlnd,

Many thanks for you project. It's very usefull to us for quite some times now and works very well.

Except I've got this bug on ubuntu where character expansion from the flash makefile target that writes the jlink flash command file does not get expanded.

I'm talking more precisely about this snippet:

flash.jlink:
        echo "r\nloadbin $(BIN) $(FLASH_START_ADDRESS)\nr\ng\nexit\n" > flash.jlink

When I look at the result of this on my OSX machine, the flash.jlink file contains

flap:ancs fmorin$ cat flash.jlink 
r
loadbin _build/application_s110.bin 
r
g
exit

Which is OK, but when I do the same thing on ubuntu, the flash.jlink file contains:

$ cat flash.jlink 
r\nloadbin _build/application_s110.bin\nr\ng\nexit\n

I tried looking on google about this but luck yet.

Thanks for your help !

honnet commented 10 years ago

Hi @fredericmorin, Sometimes you need to use an argument such as "-e"... ...but if you use /bin/echo it might solve your problem too. May the force be with you! ;)

fredericmorin commented 10 years ago

Ah nice, that seems to do it. I'll submit a patch

honnet commented 10 years ago

Cool ;)

honnet commented 10 years ago

PS: @fredericmorin, did you test it on different platforms ? (one of my 2 suggestions might not work everywhere and it might be the "-e")

fredericmorin commented 10 years ago

Yes I did test on both OSX and ubuntu both proposed solution. /bin/bash doesnt work on ubuntu(linux) adding -e works

honnet commented 10 years ago

Awesome (I have Ubuntu 12.04 and I think I have to use /bin/echo but my version is old)

hlnd commented 10 years ago

When using this setup on Ubuntu 13.10, I am not able to replicate this problem, and make flash.jlink correctly inserts proper newlines. I tested -e on the only OS X machine I have access to, and it didn't work, so I'm honestly a little at loss...

Anyway, after Googling a little, I found this, so I just pushed a commit which replaces the use of echo with printf instead, which as far as I can see works both on Ubuntu and OS X. Let me know if you see any further problems with this!

fredericmorin commented 10 years ago

That works great ! Good idea. Thanks !