Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Bash string manipulation in Kconfig
@ 2012-09-03 18:56 Stefan Fröberg
  2012-09-03 19:08 ` Thomas Petazzoni
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Fröberg @ 2012-09-03 18:56 UTC (permalink / raw)
  To: buildroot

Hello everyone.

What is the equivalent buildroot thing for handling the following bash
string stuff ?

FULL_DOWNLOAD_URL="http://www.somedomain.com/blah/blah2/blahblahblah/somefile"
FILE=${FULL_DOWNLOAD_URL##*/}
echo ${FILE}

That will correctly print only the last part of the url, "somefile"

But how to do similar in buildroot  .mk files ???

Best regards
Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 18:56 [Buildroot] Bash string manipulation in Kconfig Stefan Fröberg
@ 2012-09-03 19:08 ` Thomas Petazzoni
  2012-09-03 19:13   ` Stefan Fröberg
  2012-09-03 19:53   ` Stefan Fröberg
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2012-09-03 19:08 UTC (permalink / raw)
  To: buildroot

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :

> But how to do similar in buildroot  .mk files ???

	$(notdir $(FOO))

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 19:08 ` Thomas Petazzoni
@ 2012-09-03 19:13   ` Stefan Fröberg
  2012-09-03 19:53   ` Stefan Fröberg
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Fröberg @ 2012-09-03 19:13 UTC (permalink / raw)
  To: buildroot

3.9.2012 22:08, Thomas Petazzoni kirjoitti:
> Le Mon, 03 Sep 2012 21:56:31 +0300,
> Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :
>
>> But how to do similar in buildroot  .mk files ???
> 	$(notdir $(FOO))
>
> Thomas
Thanks Thomas!

That was fast :)

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 19:08 ` Thomas Petazzoni
  2012-09-03 19:13   ` Stefan Fröberg
@ 2012-09-03 19:53   ` Stefan Fröberg
  2012-09-03 20:01     ` Thomas Petazzoni
  2012-09-03 20:07     ` Yann E. MORIN
  1 sibling, 2 replies; 9+ messages in thread
From: Stefan Fröberg @ 2012-09-03 19:53 UTC (permalink / raw)
  To: buildroot

3.9.2012 22:08, Thomas Petazzoni kirjoitti:
> Le Mon, 03 Sep 2012 21:56:31 +0300,
> Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :
>
>> But how to do similar in buildroot  .mk files ???
> 	$(notdir $(FOO))
>
> Thomas

One more question:

Why does not the following work ?

FULL_DOWNLOAD_URL=http://www.somedomain.com/blah/blah/somefile1
FULL_DOWNLOAD_URL+=http://www.somedomain2.com/blah2/blah2/blah/somefile2

for i in $(FULL_DOWNLOAD_URL);do \
    echo $(notdir $$i) ; \
done

I expect it to print:

somefile1
somefile2

But it prints instead:

http://www.somedomain.com/blah/blah/somefile1
http://www.somedomain2.com/blah2/blah2/blah/somefile2

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 19:53   ` Stefan Fröberg
@ 2012-09-03 20:01     ` Thomas Petazzoni
  2012-09-03 20:07       ` Stefan Fröberg
  2012-09-03 20:07     ` Yann E. MORIN
  1 sibling, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2012-09-03 20:01 UTC (permalink / raw)
  To: buildroot

Le Mon, 03 Sep 2012 22:53:52 +0300,
Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :

> for i in $(FULL_DOWNLOAD_URL);do \
>     echo $(notdir $$i) ; \

Inside this for loop, what you're writing is shell code, not make code.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 20:01     ` Thomas Petazzoni
@ 2012-09-03 20:07       ` Stefan Fröberg
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Fröberg @ 2012-09-03 20:07 UTC (permalink / raw)
  To: buildroot

3.9.2012 23:01, Thomas Petazzoni kirjoitti:
> Le Mon, 03 Sep 2012 22:53:52 +0300,
> Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :
>
>> for i in $(FULL_DOWNLOAD_URL);do \
>>     echo $(notdir $$i) ; \
> Inside this for loop, what you're writing is shell code, not make code.
>
> Thomas
And because that notdir is buildroot make construct I can't use it
inside for-loop ?
Can you suggest another way to extract file part from variable that
contains bunch of URL's in for-loop ?

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 19:53   ` Stefan Fröberg
  2012-09-03 20:01     ` Thomas Petazzoni
@ 2012-09-03 20:07     ` Yann E. MORIN
  2012-09-03 20:12       ` Stefan Fröberg
  2012-09-04  5:53       ` Arnout Vandecappelle
  1 sibling, 2 replies; 9+ messages in thread
From: Yann E. MORIN @ 2012-09-03 20:07 UTC (permalink / raw)
  To: buildroot

Stefan, All,

On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:
> 3.9.2012 22:08, Thomas Petazzoni kirjoitti:
> > Le Mon, 03 Sep 2012 21:56:31 +0300,
> > Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :
> >
> >> But how to do similar in buildroot  .mk files ???
> > 	$(notdir $(FOO))
> >
> > Thomas
> 
> One more question:
> 
> Why does not the following work ?
> 
> FULL_DOWNLOAD_URL=http://www.somedomain.com/blah/blah/somefile1
> FULL_DOWNLOAD_URL+=http://www.somedomain2.com/blah2/blah2/blah/somefile2
> 
> for i in $(FULL_DOWNLOAD_URL);do \
>     echo $(notdir $$i) ; \
> done
> 
> I expect it to print:
> 
> somefile1
> somefile2
> 
> But it prints instead:
> 
> http://www.somedomain.com/blah/blah/somefile1
> http://www.somedomain2.com/blah2/blah2/blah/somefile2

That's because $(notdir ...) is onterpreted by make, while $i is
interpreted by the shell.

In your case, you'd want to use the shell constrcut:
  for i in $(FULL_DOWNLOAD_URL);do \
      echo $${i##*/} ; \
  done

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 20:07     ` Yann E. MORIN
@ 2012-09-03 20:12       ` Stefan Fröberg
  2012-09-04  5:53       ` Arnout Vandecappelle
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Fröberg @ 2012-09-03 20:12 UTC (permalink / raw)
  To: buildroot

3.9.2012 23:07, Yann E. MORIN kirjoitti:
> Stefan, All,
>
> On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:
>> 3.9.2012 22:08, Thomas Petazzoni kirjoitti:
>>> Le Mon, 03 Sep 2012 21:56:31 +0300,
>>> Stefan Fr?berg <stefan.froberg@petroprogram.com> a ?crit :
>>>
>>>> But how to do similar in buildroot  .mk files ???
>>> 	$(notdir $(FOO))
>>>
>>> Thomas
>> One more question:
>>
>> Why does not the following work ?
>>
>> FULL_DOWNLOAD_URL=http://www.somedomain.com/blah/blah/somefile1
>> FULL_DOWNLOAD_URL+=http://www.somedomain2.com/blah2/blah2/blah/somefile2
>>
>> for i in $(FULL_DOWNLOAD_URL);do \
>>     echo $(notdir $$i) ; \
>> done
>>
>> I expect it to print:
>>
>> somefile1
>> somefile2
>>
>> But it prints instead:
>>
>> http://www.somedomain.com/blah/blah/somefile1
>> http://www.somedomain2.com/blah2/blah2/blah/somefile2
> That's because $(notdir ...) is onterpreted by make, while $i is
> interpreted by the shell.
>
> In your case, you'd want to use the shell constrcut:
>   for i in $(FULL_DOWNLOAD_URL);do \
>       echo $${i##*/} ; \
>   done
>
> Regards,
> Yann E. MORIN.
>
Ah... I see
Thanks Yann!
And Thanks Thomas!

These shell-make mixing is so confusing ....

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] Bash string manipulation in Kconfig
  2012-09-03 20:07     ` Yann E. MORIN
  2012-09-03 20:12       ` Stefan Fröberg
@ 2012-09-04  5:53       ` Arnout Vandecappelle
  1 sibling, 0 replies; 9+ messages in thread
From: Arnout Vandecappelle @ 2012-09-04  5:53 UTC (permalink / raw)
  To: buildroot

On 09/03/12 22:07, Yann E. MORIN wrote:
> Stefan, All,
>
> On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:
>> 3.9.2012 22:08, Thomas Petazzoni kirjoitti:
>>> Le Mon, 03 Sep 2012 21:56:31 +0300,
>>> Stefan Fr?berg<stefan.froberg@petroprogram.com>  a ?crit :
>>>
>>>> But how to do similar in buildroot  .mk files ???
>>> 	$(notdir $(FOO))
>>>
>>> Thomas
>> One more question:
>>
>> Why does not the following work ?
>>
>> FULL_DOWNLOAD_URL=http://www.somedomain.com/blah/blah/somefile1
>> FULL_DOWNLOAD_URL+=http://www.somedomain2.com/blah2/blah2/blah/somefile2
>>
>> for i in $(FULL_DOWNLOAD_URL);do \
>>      echo $(notdir $$i) ; \
>> done
>>
>> I expect it to print:
>>
>> somefile1
>> somefile2
>>
>> But it prints instead:
>>
>> http://www.somedomain.com/blah/blah/somefile1
>> http://www.somedomain2.com/blah2/blah2/blah/somefile2
> That's because $(notdir ...) is onterpreted by make, while $i is
> interpreted by the shell.
>
> In your case, you'd want to use the shell constrcut:
>    for i in $(FULL_DOWNLOAD_URL);do \
>        echo $${i##*/} ; \
>    done
>

  Actually, in this case you just want
$(notdir $(FULL_DOWNLOAD_URL))

(the notdir function can take a list of filenames).


  Regards,
  Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-09-04  5:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-03 18:56 [Buildroot] Bash string manipulation in Kconfig Stefan Fröberg
2012-09-03 19:08 ` Thomas Petazzoni
2012-09-03 19:13   ` Stefan Fröberg
2012-09-03 19:53   ` Stefan Fröberg
2012-09-03 20:01     ` Thomas Petazzoni
2012-09-03 20:07       ` Stefan Fröberg
2012-09-03 20:07     ` Yann E. MORIN
2012-09-03 20:12       ` Stefan Fröberg
2012-09-04  5:53       ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox