dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yaroslav Halchenko <yoh@onerussian.com>
To: dash@vger.kernel.org
Cc: Kyle Meyer <kyle@kyleam.com>
Subject: stalls whenever PS4 contains $() and set -x
Date: Mon, 25 May 2020 09:41:15 -0400	[thread overview]
Message-ID: <20200525134115.GO423431@lena.dartmouth.edu> (raw)

Dear DASH maintainer(s),

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:

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 '

- posh:
exit:130 /tmp > posh test.sh
+export PS4=+ $(date +%T.%N) [$$] 
+ $(date +%T.%N) [$$] echo lets go
lets go
+ $(date +%T.%N) [$$] sleep 1
+ $(date +%T.%N) [$$] echo done 

- dash: (stalls it set -x)

/tmp > dash test.sh        
+export PS4=+ $(date +%T.%N) [$$] 

Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        

             reply	other threads:[~2020-05-25 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 13:41 Yaroslav Halchenko [this message]
2020-05-27  3:19 ` [PATCH] eval: Prevent recursive PS4 expansion Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200525134115.GO423431@lena.dartmouth.edu \
    --to=yoh@onerussian.com \
    --cc=dash@vger.kernel.org \
    --cc=kyle@kyleam.com \
    --subject='Re: stalls whenever PS4 contains $() and set -x' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).