I think the results can be processed through methods such as `printf %q` or `"${result@Q}"`
---- Replied Message ---- | From | Zachary Santer<zsan...@gmail.com> | | Date | 01/30/2024 22:11 | | To | A4-Tacks<wdsjxhno1...@163.com> | | Cc | bug-bash@gnu.org | | Subject | Re: About `M-C-e` expand result `'` failed | On Tue, Jan 30, 2024 at 6:48 AM Zachary Santer <zsan...@gmail.com> wrote: Would it be unreasonable to expect that the argument to the outermost echo after M-C-e still be in double-quotes? Or potentially placed in single-quotes. That way, the line would be evaluated the same way as it would've been without M-C-e. Double-quoting is probably the way to go in that case, but then the M-C-e logic has to also be smart enough to backslash escape things so the line gets evaluated the same way as it otherwise would've been. And single-quotes should be left in place as well. $ var='foo' $ echo "$( echo '${var}' )" # enter ${var} $ echo "$( echo '${var}' )" # M-C-e $ echo ${var} # enter foo # Would've expected: echo "\${var}" $ echo $( echo '${var}' ) # enter ${var} $ echo $( echo '${var}' ) # M-C-e $ echo ${var} # enter foo # Would've expected: echo \${var} $ echo '${var}' # enter ${var} $ echo '${var}' # M-C-e $ echo ${var} # enter foo # Would've expected: echo '${var}' $ echo "${var}" # enter foo $ echo "${var}" # M-C-e $ echo foo foo # Would've expected: echo "foo" From the manual: > 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. See HISTORY EXPANSION > below for a description of history expansion. Doesn't list quote removal.