Skip to contentSkip to conversation

Bash string manipulation in Kconfig

Buildroot Stefan Fröberg 4 participants 9 messages Sep 3, 2012 – Sep 4, 2012

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 1 line

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

	$(notdir $(FOO))

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

3.9.2012 22:08, Thomas Petazzoni kirjoitti:

Quoted 7 lines

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 1 line

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

	$(notdir $(FOO))

Thomas

Thanks Thomas!

That was fast :)

Stefan

#3 lore raw
In reply to Thomas Petazzoni

3.9.2012 22:08, Thomas Petazzoni kirjoitti:

Quoted 7 lines

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 1 line

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

#4 lore raw

Le Mon, 03 Sep 2012 22:53:52 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 2 lines
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

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw

3.9.2012 23:01, Thomas Petazzoni kirjoitti:

Quoted 8 lines

Le Mon, 03 Sep 2012 22:53:52 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 2 lines
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

#6 lore raw
In reply to Stefan Fröberg

Stefan, All,

Quoted 22 lines · On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:

3.9.2012 22:08, Thomas Petazzoni kirjoitti:

Quoted 7 lines

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 1 line

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:

Quoted 7 lines

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.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

3.9.2012 23:07, Yann E. MORIN kirjoitti:

Quoted 34 lines

Stefan, All,

Quoted 21 lines · On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:

3.9.2012 22:08, Thomas Petazzoni kirjoitti:

Quoted 7 lines

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg <[email protected]> a ?crit :

Quoted 1 line

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:

Quoted 7 lines

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.

Quoted 8 lines

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

#8 lore raw
In reply to Yann E. MORIN
Quoted 31 lines · Yann E. MORIN

Stefan, All,

Quoted 21 lines · On Monday 03 September 2012 21:53:52 Stefan Fr?berg wrote:

3.9.2012 22:08, Thomas Petazzoni kirjoitti:

Quoted 7 lines

Le Mon, 03 Sep 2012 21:56:31 +0300,
Stefan Fr?berg<[email protected]> a ?crit :

Quoted 1 line

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:

Quoted 7 lines

somefile1
somefile2

But it prints instead:

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

Quoted 8 lines

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

Signature · 6 lines
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