Sunday, October 07, 2018

Re: ksh equivalent to shell-expand-line

Klemens Nanni wrote:
> On Sat, Oct 06, 2018 at 09:38:42PM +0200, John Ankarström wrote:
>> Is there a way for ksh to expand a $(command substitution) without having to
>> execute the entire line?
> No.

That's too bad.

>> bash provides this via shell-expand-line (bound to Ctrl-Alt-e by default),
> From bash(1):
>
> shell-expand-line (M-C-e)
> Expand the line as the shell does. This performs alias and
> history expansion as well as all of the shell word expansions.
>
> 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

There is a discussion about this behavior on the bug-bash mailing list:

https://lists.gnu.org/archive/html/bug-bash/2016-11/msg00010.html

Turns out to be a relatively simple fix, but the old behavior will
remain the default (as of 2016).

>> and ksh seems to have expand-file, but that only works for filenames.
> We have no other expanding functions.

Would there be any interest among the pdksh developers in a function
like shell-expand-line (but which works properly), if somebody like me
did the work?

Best regards,
John

No comments:

Post a Comment