diff options
author | Denys Vlasenko | 2021-09-09 16:26:41 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-09-09 16:29:37 +0200 |
commit | eb607777697f4c5eb2dfd86e5837a8c379f65979 (patch) | |
tree | b623e6d90bd7a2dfdb2e48226e3c4757e11affdd /libbb/remove_file.c | |
parent | 48cb983b136fb74c61db594a30e18bdc42b7264c (diff) | |
download | busybox-eb607777697f4c5eb2dfd86e5837a8c379f65979.zip busybox-eb607777697f4c5eb2dfd86e5837a8c379f65979.tar.gz |
ash: eval: Prevent recursive PS4 expansion
Date: Wed, 27 May 2020 13:19:10 +1000
eval: Prevent recursive PS4 expansion
Yaroslav Halchenko <yoh@onerussian.com> wrote:
> I like to (ab)use PS4 and set -x for tracing execution of scripts.
> Reporting time and PID is very useful in this context.
>
> I am not 100% certain if bash's behavior (of actually running the command
> embedded within PS4 string, probably eval'ing it) is actually POSIX
> compliant, posh seems to not do that; but I think it is definitely not
> desired for dash to just stall:
>
> - the script:
> #!/bin/sh
> set -x
> export PS4='+ $(date +%T.%N) [$$] '
> echo "lets go"
> sleep 1
> echo "done $var"
>
> - bash:
> /tmp > bash --posix test.sh
> +export 'PS4=+ $(date +%T.%N) [$$] '
> +PS4='+ $(date +%T.%N) [$$] '
> + 09:15:48.982296333 [2764323] echo 'lets go'
> lets go
> + 09:15:48.987829613 [2764323] sleep 1
> + 09:15:49.994485037 [2764323] echo 'done '
> done
>
...
> - dash: (stalls it set -x)
> /tmp > dash test.sh
> +export PS4=+ $(date +%T.%N) [$$]
> ^C^C
This patch fixes the infinite loop caused by repeated expansions
of PS4.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/remove_file.c')
0 files changed, 0 insertions, 0 deletions