Bash - String manipulation in Makefile

I've learned about string manipulation with bash, and more especially about substring replacement:

#! /bin/bash

VAR1="aaaa.bbbb.cccc"
VAR2="bbbb*"
echo ${VAR1%${VAR2}}

This bash script prints "aaaa.". I tried to include it in my makefile, but I can't make it work..

SHELL:=/bin/bash

VAR1="aaaa.bbbb.cccc"
VAR2="bbbb*"

all:
    @echo $${VAR1%$${VAR2}}

This Makefile only prints a blank line. I think I've misunderstood something, but can't figure out what. Any help would be really appreciated.

Answers


No need to put double quotes around VAR1 and VAR2. And you need to use export if you want to put VAR1 and VAR2 above all:

SHELL:=/bin/bash

export VAR1=aaaa.bbbb.cccc
export VAR2=bbbb*

all:
    @echo $${VAR1%$${VAR2}}

Need Your Help

Encapsulating ListBox in public property

c# .net winforms properties mvp

In a MVP applicaiton if I want to encapsulate a ListBox in a public property so that I could expose the property through an interface to the presenter. I should be able to update the items in the L...

JQuery ajax div

jquery ajax html

I Have a a list of contacts like this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.