[PATCH] ash: fix command name of shell scripts
mikma.bbne at lists.m7n.se
mikma.bbne at lists.m7n.se
Mon Oct 11 12:24:37 UTC 2021
I forgot to mention that the issue isn't triggered by the default
busybox configuration.
I noticed the issue in OpenWrt which uses
CONFIG_FEATURE_PREFER_APPLETS=y by default,
and that option triggers the issue.
Config.in says it's an experimental option. Does it mean it isn't
recommended, and that
OpenWrt maybe shouldn't enable it by default?
/Mikael
On 2021-10-11 02:58, Denys Vlasenko wrote:
> On Sun, Oct 10, 2021 at 11:09 PM <mikma.bbne at lists.m7n.se> wrote:
>> Hello,
>>
>> when executing a script with ash from busybox in the shebang then the command name will contain "sh" instead of the name of the script as expected.
> Can't reproduce: I see script name in comm field, not "sh" or "ash":
>
> $ cat comm.tests
> {
> echo "#!$THIS_SH"
> echo 'procdir=/proc/$$'
> echo 'echo " /proc/N/exe: $(basename $(readlink $procdir/exe))"'
> echo 'echo " /proc/N/comm: $(cat $procdir/comm)"'
> } >SCRIPT.sh
> chmod 755 SCRIPT.sh
> echo ./SCRIPT.sh:
> ./SCRIPT.sh
> echo "exec ./SCRIPT.sh:"
> (exec ./SCRIPT.sh)
> echo sh ./SCRIPT.sh:
> $THIS_SH ./SCRIPT.sh
> rm SCRIPT.sh
>
> $ THIS_SH=/bin/bash bash comm.tests
> ./SCRIPT.sh:
> /proc/N/exe: bash
> /proc/N/comm: SCRIPT.sh
> exec ./SCRIPT.sh:
> /proc/N/exe: bash
> /proc/N/comm: SCRIPT.sh
> sh ./SCRIPT.sh:
> /proc/N/exe: bash
> /proc/N/comm: bash
>
> $ THIS_SH=/bin/ash ash comm.tests
> ./SCRIPT.sh:
> /proc/N/exe: ash
> /proc/N/comm: SCRIPT.sh
> exec ./SCRIPT.sh:
> /proc/N/exe: ash
> /proc/N/comm: SCRIPT.sh
> sh ./SCRIPT.sh:
> /proc/N/exe: ash
> /proc/N/comm: ash
>
> $ ash --help
> BusyBox v1.35.0.git (2021-09-07 23:38:50 CEST) multi-call binary.
> ...
>
> $ bash --help
> GNU bash, version 5.0.17(1)-release-(x86_64-redhat-linux-gnu)
> ...
More information about the busybox
mailing list