On Sun, Oct 07, 2018 at 10:13:16AM +0200, Otto Moerbeek wrote:
> On Sun, Oct 07, 2018 at 08:48:52AM +0200, Tomasz Rola wrote:
> 
> > On Sun, Oct 07, 2018 at 12:03:31AM +0200, Klemens Nanni wrote:
> > > On Sat, Oct 06, 2018 at 09:38:42PM +0200, John Ankarström wrote:
> > [...]
> > > And yet, it disregards quoting and will errornously expand the following
> > > example into multiple words instead of one:
> > > 
> > >   bash-4.4$ echo "$(echo a b)"
> > >   bash-4.4$ echo a b
> > 
> > Just in case it matters to anybody:
> > 
> >   $ echo "$(echo a b)"
> > a b
> >   $   bash --version
> > GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
> > 
> > Looks like something changed in between?
> 
> This is not about executing the line, it's abouty expanding using Ctrl-Alt-e

I can see now (side note to myself: do not ever never again reply to
emails before going to sleep at morning, sorry).

So, can this problem be described as that OP cannot expand this stuff
in his memory (this jello ram between the ears), because it has got
too complicated? Perhaps this can be helped by writing things into a
proper script? I performed a lot of $() things in cli but never
learned about M-C-e, so I assume I never did things that required this
trick. Hence a script suggestion.

Another trick may be executing the line with echo prepended - should
do all expansions and write what will be executed. I think it is not
going to work too well if for loop is being echoed, and other such
things, so perhaps quoting a command and echoing would do the job.

Seems like it works in bash as I hoped:

==>$ echo "for i in $(seq 3); do circle ${i}; done"
for i in 1
2
3; do circle ; done

HTH
-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.      **
** As the answer, master did "rm -rif" on the programmer's home    **
** directory. And then the C programmer became enlightened...      **
**                                                                 **
** Tomasz Rola          mailto:tomasz_r...@bigfoot.com             **

Reply via email to