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: Eduardo A . Bustamante López
Subject: Re: [Help-bash] How to not print command in $() when set -v is enabled?
Date: Mon, 10 Feb 2014 07:24:07 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Feb 10, 2014 at 08:57:38AM -0600, Peng Yu wrote:
> Hi,
> 
> The following example shows that the 2nd echo is also printed. Since
> it is in $(), a better behavior might be not to print it. Is there a
> way to do so in bash? Thanks.
> 
> ~/linux/test/bash/man/builtin/set/-v/$($ cat main.sh
> #!/usr/bin/env bash
> 
> set -v
> echo "$(echo "Hello World!")"
> ~/linux/test/bash/man/builtin/set/-v/$($ ./main.sh
> echo "$(echo "Hello World!")"
> echo "Hello World!")"
> echo "Hello World!")
> echo "Hello World!"
> Hello World!
> 
It's really hard to tell from your example what's part of the command
line and what's not... your prompt is a bit weird.

Though, why would not want it to get printed? The point of -v/-x is
to trace the execution of commands inside a script, and commands
executed in command substitution are still commands that have an
effect on the flow, so... let's keep them in the output :)?

-- 
Eduardo Alan Bustamante López



reply via email to

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