help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to not print command in $() when set -v is enabled?


From: Greg Wooledge
Subject: Re: [Help-bash] How to not print command in $() when set -v is enabled?
Date: Mon, 10 Feb 2014 10:28:32 -0500
User-agent: Mutt/1.4.2.3i

On Mon, Feb 10, 2014 at 08:57:38AM -0600, Peng Yu wrote:
> ~/linux/test/bash/man/builtin/set/-v/$($ cat main.sh

That's the most confusing shell prompt I've ever seen.  I guess both $
signs are part of the prompt, and not the command you're typing...?

> ~/linux/test/bash/man/builtin/set/-v/$($ ./main.sh
> echo "$(echo "Hello World!")"
> echo "Hello World!")"
> echo "Hello World!")
> echo "Hello World!"
> Hello World!

I'd say the real question here is why set -v prints the input line four
times (one complete, and three partial) instead of just once or twice.

That said, set -v isn't very useful, so almost nobody uses it.  So the
real answer to your question is probably "nobody ever noticed it before".

On the other hand, the behavior appears to have changed over time, so
there could be a case made that this is a bug/regression:

imadev:~$ cat foo
#!/bin/bash
echo "foo $(tr a b <<< baa) bar"

imadev:~$ bash-2.05b -v foo
#!/bin/bash
echo "foo $(tr a b <<< baa) bar"
tr a b <<< baa
foo bbb bar

imadev:~$ bash-3.2 -v foo
#!/bin/bash
echo "foo $(tr a b <<< baa) bar"
tr a b <<< baa
foo bbb bar

imadev:~$ bash-4.0 -v foo
#!/bin/bash
echo "foo $(tr a b <<< baa) bar"
tr a b <<< baa) bar"
tr a b <<< baa) bar
tr a b <<< baa
foo bbb bar

Looks like the behavior changed in 4.0.  Previous versions print the full
line as it's read, and then the inner command, but not the two weird
partials in between.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]