Re: Echoing commands

2024-06-13 Thread Robert Elz
Date:Thu, 13 Jun 2024 11:51:13 -0400 From:"Dale R. Worley" Message-ID: <87jzisx2mm@hobgoblin.ariadne.com> | For instance, how should this be logged? | | $ { echo foo ; echo bar ; } >/dev/null In the NetBSD shell: [jacaranda]{2}$ { echo foo ; echo bar

Re: Echoing commands

2024-06-13 Thread Robert Elz
Date:Wed, 12 Jun 2024 19:31:13 +0200 From:Angelo Borsotti Message-ID: | I would stress the importance of this: the purpose of scripts is | to execute commands, Yes. | informing the caller of what they execute, No. If a script wants to provide output like

Re: Echoing commands

2024-06-13 Thread Greg Wooledge
On Thu, Jun 13, 2024 at 11:51:13AM -0400, Dale R. Worley wrote: > For instance, how should this be logged? > > $ { echo foo ; echo bar ; } >/dev/null > + echo foo > + echo bar I'm 99% sure I know what answer the OP of this thread will give: "It should write '{ echo foo ; echo bar ; }

Re: Echoing commands

2024-06-13 Thread Dale R. Worley
Angelo Borsotti writes: > the solution to show commands with "set -x" has, however, a flow: it > does not show properly commands that contain redirections. E.g., ... > cat f1.txt f1.txt > f1.tmp But showing redirections properly is difficult, not just in the implementation, but in what it *means*

Re: Echoing commands

2024-06-13 Thread Greg Wooledge
On Thu, Jun 13, 2024 at 10:01:16AM +0200, Angelo Borsotti wrote: > @echo-on > cat f1.txt f1.txt > f1.tmp > @echo-off > > I.e. the command is not entirely displayed. Yeah. This is what I mentioned originally: set -x does not show redirections. Ever. There is no workaround for this currently. A

Re: Echoing commands

2024-06-13 Thread Angelo Borsotti
Dear all, the solution to show commands with "set -x" has, however, a flow: it does not show properly commands that contain redirections. E.g., let tmp.sh be: #!/bin/bash shopt -s expand_aliases alias @echo-on='set -x' alias @echo-off='{ set +x; } 2>/dev/null' PS4= @echo-on cat f1.txt f1.txt > f1

Re: Echoing commands

2024-06-12 Thread Angelo Borsotti
Dear all, thank you very much for your quick replies. The solution: alias @echo-on='set -x' alias @echo-off='{ set +x; } 2>/dev/null' PS4= Solves the problem, and relieves from writing "echo COMMAND" before each command that should be shown. -Angelo Borsotti On Wed, 12 Jun 2024 at

Re: Echoing commands

2024-06-12 Thread Koichi Murase
2024年6月13日(木) 5:20 Angelo Borsotti : > This is not the same as debugging, for which set -x is devoted. > "set -x" makes the ensuing commands be printed, but prefixed > with "+ ", which makes the result look ugly, PS4= (as Greg has replied) > not to mention that > the following "set +x" is echoed

Re: Echoing commands

2024-06-12 Thread alex xmb sw ratchev
args1() { printf %s\ "${@@K}" ; printf \\n ; } ; args1 echo foo ; args1 echo two three On Wed, Jun 12, 2024, 10:58 PM alex xmb sw ratchev wrote: > there are two output lines , for the two cmds , sorry gmail problem > > On Wed, Jun 12, 2024, 10:57 PM alex xmb sw ratchev > wrote: > >> ~ $ args1(

Re: Echoing commands

2024-06-12 Thread alex xmb sw ratchev
there are two output lines , for the two cmds , sorry gmail problem On Wed, Jun 12, 2024, 10:57 PM alex xmb sw ratchev wrote: > ~ $ args1() { printf %s\ "${@@K}" ; printf \\n ; } ; args1 echo foo ; > args1 echo two three 'echo' 'foo' > 'echo' 'two' 'three' > ~ $ > > On Wed, Jun 12, 2024, 10:5

Re: Echoing commands

2024-06-12 Thread alex xmb sw ratchev
~ $ 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 wrote: > ~ $ logf=$HOME/alog1 ; run1() { printf '%(%F+%T%z)T %s' -1 "$1" >>"$logf" > ; (( $# > 1 )) && printf \ %

Re: Echoing commands

2024-06-12 Thread alex xmb sw ratchev
~ $ 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 wrote: > On Wed, Jun 1

Re: Echoing commands

2024-06-12 Thread Greg Wooledge
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

Echoing commands

2024-06-12 Thread Angelo Borsotti
Hi, I am running bash 5.2.15(3)-release (x86_64-pc-cygwin) on cygwin running on Windows 10. Bash lacks a proper way of echoing commands, which is present in other shells, even in ones which are much less powerful, like, e.g. Windows CMD. This is not the same as debugging, for which set -x is

Re: Echoing commands in vi visual mode

2014-07-03 Thread Chet Ramey
On 7/2/14, 2:22 AM, Filip Krska wrote: > Of course, treat the patch rather as proof of concept, there may be side > effect I'm not aware. There's a more direct one-line patch I'm looking at. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita b

Re: Echoing commands in vi visual mode

2014-07-02 Thread Filip Krska
Hi Chet, On 06/30/2014 08:55 PM, Chet Ramey wrote: On 6/26/14, 4:56 AM, Ondrej Oprala wrote: On 06/11/2014 07:26 PM, Chet Ramey wrote: On 6/11/14, 6:35 AM, Ondrej Oprala wrote: Hi, bash-4.3 seems to act differently(better) in vi visual mode, than previous bash-4 minors. However, ksh gave a di

Re: Echoing commands in vi visual mode

2014-06-30 Thread Chet Ramey
On 6/26/14, 4:56 AM, Ondrej Oprala wrote: > On 06/11/2014 07:26 PM, Chet Ramey wrote: >> On 6/11/14, 6:35 AM, Ondrej Oprala wrote: >>> Hi, >>> bash-4.3 seems to act differently(better) in vi visual mode, than previous >>> bash-4 minors. >>> However, ksh gave a different result all along. >> This is

Re: Echoing commands in vi visual mode

2014-06-26 Thread Ondrej Oprala
On 06/11/2014 07:26 PM, Chet Ramey wrote: On 6/11/14, 6:35 AM, Ondrej Oprala wrote: Hi, bash-4.3 seems to act differently(better) in vi visual mode, than previous bash-4 minors. However, ksh gave a different result all along. This isn't standardized, so I'm not worried about small differences b

Re: Echoing commands in vi visual mode

2014-06-11 Thread Chet Ramey
On 6/11/14, 6:35 AM, Ondrej Oprala wrote: > Hi, > bash-4.3 seems to act differently(better) in vi visual mode, than previous > bash-4 minors. > However, ksh gave a different result all along. This isn't standardized, so I'm not worried about small differences between implementations in something t

Echoing commands in vi visual mode

2014-06-11 Thread Ondrej Oprala
Hi, bash-4.3 seems to act differently(better) in vi visual mode, than previous bash-4 minors. However, ksh gave a different result all along. Steps to reproduce: 1. set -o vi 2. meta+k 3. v 4. for i in $(seq 10); do j=$( echo $i$i ); echo $j; done echo second # save and close the editor Results