|
From: | Dan Church |
Subject: | Re: Bug: Subshell won't continue after .-sourcing a file |
Date: | Thu, 22 Dec 2022 11:37:45 -0600 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 |
Awesome Chet!Confirmed fixed by your patch. Do you think you'll include my test for the bug?
Here is an updated script that uses proper quoting everywhere: sub1=$(mktemp) sub2=$(mktemp) sub3=$(mktemp) echo "( echo '1st script executing' ; . ${sub2@Q} ; echo '1st script still executing' )" >"$sub1" echo "echo '2nd script starting' && ${THIS_SH@Q} ${sub3@Q}" >"$sub2" echo "echo '3rd script starting'" >"$sub3" . "$sub1"Turns out the best time to find bugs in your code is when demoing it for someone else. :-)
On 12/22/22 11:18 AM, Chet Ramey wrote:
On 12/21/22 11:44 PM, Oğuz wrote:22 Aralık 2022 Perşembe tarihinde Dan Church <h3xx@gmx.com> yazdı:Repro: sub1=$(mktemp) sub2=$(mktemp) sub3=$(mktemp)echo '( echo "1st script executing" ; . '"$sub2"' ; echo "1st scriptstill executing" )' >"$sub1" echo 'echo "2nd script starting" && ${THIS_SH} '"$sub3" >"$sub2" echo 'echo "3rd script starting"' >"$sub3" . "$sub1" "1st script still executing" will never be printed.Or $ bash -c '(. <(echo ": && uname"); echo x)' Linux $ x is never printed. Looks like another bug caused by aggressive subshell optimizationsThanks for the reports, both of you. I've attached a patch. Chet
-- Regards, Dan Church 🌎 web: h3xx.codeberg.page <https://h3xx.codeberg.page/>"If I am to be judged by those who come after me, let me be judged for the truth." — Raistlin Majere
[Prev in Thread] | Current Thread | [Next in Thread] |