[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $PS5, for sh -v!
From: |
Greg Wooledge |
Subject: |
Re: $PS5, for sh -v! |
Date: |
Wed, 4 Apr 2018 08:35:25 -0400 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Wed, Apr 04, 2018 at 11:25:26AM +0800, 積丹尼 Dan Jacobson wrote:
> $PS4 is for sh -x. Well, $PS5 or $PSv should be for sh -v!
>
> Imagine, with just a simple PS5='$ ', one could produce
> perfect dialogues,
>
> $ set -eu /tmp/x
> $ mkdir $@
> $ cd $@
> $ seq 3|xargs touch
> $ ls -U $@
> 3 2 1
Until you use a compound command like "if" or "for" or "while", or a
function. Then you suddenly realize how utterly useless sh -v actually
is, and why nobody ever bothers with it.
sh -v echoes lines as they ae *read* by the shell, not as they are
executed. In the case of a compound command, the entire command has
to be read before execution can begin.
If the script consists almost entirely of a while loop (pretty common),
then the entire while loop (i.e. the vast majority of the script)
has to be read, and thus echoed by -v, before anything in the loop
actually happens.
- $PS5, for sh -v!, 積丹尼 Dan Jacobson, 2018/04/03
- Re: $PS5, for sh -v!,
Greg Wooledge <=