bug-bash
[Top][All Lists]
Advanced

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

Re: Echoing commands


From: alex xmb sw ratchev
Subject: Re: Echoing commands
Date: Wed, 12 Jun 2024 22:57:27 +0200

~ $ args1() { printf %s\  "${@@K}" ; printf \\n ; } ; args1 echo foo ;
args1 echo two three   'echo' 'foo'
'echo' 'two' 'three'
~ $

On Wed, Jun 12, 2024, 10:52 PM alex xmb sw ratchev <fxmbsw7@gmail.com>
wrote:

> ~ $ logf=$HOME/alog1 ; run1() { printf '%(%F+%T%z)T %s' -1 "$1" >>"$logf"
> ; (( $# > 1 )) && printf \ %s "${@:2}" >>"$logf" ; "$@" ; >>"$logf" printf
> \\n ; } ; run1 echo foo ; cat "$logf"
> foo
> 2024-06-12+22:51:31+0200 echo foo
> ~ $
>
> On Wed, Jun 12, 2024, 10:26 PM Greg Wooledge <greg@wooledge.org> wrote:
>
>> On Wed, Jun 12, 2024 at 07:31:13PM +0200, Angelo Borsotti wrote:
>> > "set -x" makes the ensuing commands be printed, but prefixed
>> > with "+ ", which makes the result look ugly, not to mention that
>> > the following "set +x" is echoed too (there are hacks to suppress
>> > the "set +x" output, but they are just hacks).
>>
>> If all you want is to remove the "+ ", you can simply set the PS4
>> variable to an empty string.
>>
>> >       set -o log
>> >       cat tmp >tmp1        # or any other command
>> >       set -o nolog
>> >
>> > producing the output on the console
>> >
>> >        cat tmp >tmp1
>>
>> If you want to retain redirections in the -x output, that's a whole
>> different issue.  There is currently no way to do that.  Chet would
>> have to implement something.
>>
>>


reply via email to

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