[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.0] Makefile: remove bashism
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH for-2.0] Makefile: remove bashism |
Date: |
Mon, 7 Apr 2014 16:38:37 +0100 |
On 7 April 2014 16:30, Markus Armbruster <address@hidden> wrote:
> Peter Maydell <address@hidden> writes:
>
>> On 5 April 2014 15:25, Michael Tokarev <address@hidden> wrote:
>>> ifneq ($(CONFIG_MODULES),)
>>> $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
>>> for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \
>>> - $(INSTALL_PROG) $(STRIP_OPT) $$s
>>> "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \
>>> + $(INSTALL_PROG) $(STRIP_OPT) $$s
>>> "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
>>> done
>>> endif
>>> ifneq ($(HELPERS-y),)
>>
>> Reviewed-by: Peter Maydell <address@hidden>
>>
>> Paolo, Fam: does this patch look ok to you? I propose
>> to apply it for 2.0...
>
> I don't understand the quoting in the old version offhand (leaning
> toothpick syndrome)
Yeah, it took me a while to figure out too, but:
$${s//\//-}
$$ is quoting a '$' for Make, so the shell sees:
${s//\//-}
and the bash syntax for this substitution is:
${parameter/pattern/string}
where if 'pattern' starts with a '/' it means 'replace
all matches', like sed's 'g' modifier
So we have:
parameter: s
pattern: /\/
string: -
and the pattern is the 'global replace' modifier
plus an escaped forward slash. So it's $s (the shell
variable) with all the forward slashes converted to hyphens.
thanks
-- PMM