help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Adding prefix to commands automatically printed when `se


From: Peng Yu
Subject: Re: [Help-bash] Adding prefix to commands automatically printed when `set -v` is enabled
Date: Mon, 30 Mar 2015 07:55:55 -0500

On Mon, Mar 30, 2015 at 6:58 AM, Greg Wooledge <address@hidden> wrote:
> On Sun, Mar 29, 2015 at 09:23:18AM -0500, Peng Yu wrote:
>> In some other languages, for example, in R, not only the command
>> running can be printed but also a prompt string is prepended to the
>> command so that it is easy to see which line is the command and which
>> line is the output. I don't think this feature is available when set
>> -v is enabled (If it is available, please let me know). If not, is it
>> a useful feature to be added to bash in the future?
>
> Why not use set -x instead?  Not only does it print a "prompt" at the
> start of each command, but you can configure its content (by setting PS4).
> I've never found a use for set -v.

See the difference below. I need to print the original command line
not some transformed version.

#!/usr/bin/env bash

set -x
ls
x=$(echo x)
echo "$x"


==> main_v.sh <==
#!/usr/bin/env bash

set -v
ls
x=$(echo x)
echo "$x"

~$ ./main.sh
+ ls
README.mkd  main.sh  main_v.sh
++ echo x
+ x=x
+ echo x
x
~$ ./main_v.sh
ls
README.mkd  main.sh  main_v.sh
x=$(echo x)
echo x
echo "$x"
x


-- 
Regards,
Peng



reply via email to

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