Re: [PATCH] kbuild: add $(BASH) to run scripts with bash-extension

From: Geert Uytterhoeven
Date: Tue Oct 01 2019 - 05:55:37 EST


Hi Yamada-san,

On Sun, Aug 25, 2019 at 3:29 PM Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> wrote:
> CONFIG_SHELL falls back to sh when bash is not installed on the system,
> but nobody is testing such a case since bash is usually installed.
> That is, shell scripts invoked by CONFIG_SHELL are only tested with
> bash.
>
> It makes it difficult to test whether the hashbang #!/bin/sh is real.
> In fact, I saw some patches trying to add bash-extension to #!/bin/sh
> script.
>
> Besides, some shell scripts invoked by CONFIG_SHELL use bash-extension
> and #!/bin/bash is specified as the hashbang, while CONFIG_SHELL may
> not always be set to bash.
>
> Probably, the right thing to do is to introduce BASH that is bash by
> default, and always set CONFIG_SHELL to sh. Replace $(CONFIG_SHELL)
> with $(BASH) for #!/bin/bash scripts.
>
> If somebody tries to add bash-extension to a #!/bin/sh script, it will
> be caught by somebody because /bin/sh is a symlink to dash on some
> major distributions.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>

This is now commit 858805b336be1cab ("kbuild: add $(BASH) to run scripts
with bash-extension").

This commit has the strange side-effect of inserting the contents of a
localversion file in the build directory twice.

Steps to reproduce:

src-dir$ echo src > localversion
build-dir$ echo build > localversion
build-dir$ make defconfig; make include/generated/utsrelease.h;
cat include/generated/utsrelease.h
...
#define UTS_RELEASE "5.3.0-rc4buildbuildsrc+"

Building in the source directory is OK.

src-dir$ make defconfig; make include/generated/utsrelease.h; cat
include/generated/utsrelease.h
...
#define UTS_RELEASE "5.3.0-rc4src+"

Changing scripts/setlocalversion to use /bin/bash does not fix the issue.

Do you have a clue?
Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds