[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fix bind -X quoting
From: |
Chet Ramey |
Subject: |
Re: [PATCH] fix bind -X quoting |
Date: |
Mon, 24 Jul 2023 13:13:19 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 7/19/23 12:47 PM, Grisha Levit wrote:
On Wed, Jul 19, 2023 at 10:47 AM Chet Ramey <chet.ramey@case.edu> wrote:
Thanks for the report. It seems like your patch is incomplete, though.
After applying it:
$ bind -x '"\eX": echo "x"'
$ bind -X
"\eX": "echo "x""
We probably need to suppress printing the double quotes around `out' if
print_readably < 0.
Oh good point. I guess we'd need to also print a backslash if the
first character of the command is a quote.
Quoted command lines are tricky. Like a regular readline key binding, a
command name that starts with a double quote is assumed to be a single
double-quoted string (like any other macro), where the double quotes get
stripped before calling rl_generic_bind. Practically, this means that you
can -- and have historically been able to -- run
bind -x '"\eX": "echo x y z"'
and have `echo x y z' executed when you type M-X.
Not only does this not permit quoted command names with arguments, you have
to detect the difference between a quoted string and a quoted command name
after all that information has been lost. Changing this means backwards-
incompatible changes to bind_keyseq_to_unix_command.
You could do it if you allowed, say
bind -x '"\eX": \"command with spaces\" \"x\"'
and then stripped the backslashes before calling rl_generic_bind, but
that's not exactly backwards compatible either.
And since the bash code parses the command like you passed it to `eval',
you can't have readline quoting double-quotes in the command string with
backslashes.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- [PATCH] fix bind -X quoting, Grisha Levit, 2023/07/18
- Re: [PATCH] fix bind -X quoting, Chet Ramey, 2023/07/19
- Re: [PATCH] fix bind -X quoting, alex xmb ratchev, 2023/07/19
- Re: [PATCH] fix bind -X quoting, Grisha Levit, 2023/07/19
- Re: [PATCH] fix bind -X quoting,
Chet Ramey <=
- Re: [PATCH] fix bind -X quoting, alex xmb ratchev, 2023/07/24
- Re: [PATCH] fix bind -X quoting, Chet Ramey, 2023/07/26
- Re: [PATCH] fix bind -X quoting, Grisha Levit, 2023/07/26
- Re: [PATCH] fix bind -X quoting, Chet Ramey, 2023/07/31
- Re: [PATCH] fix bind -X quoting, Chet Ramey, 2023/07/31
- Re: [PATCH] fix bind -X quoting, G. Branden Robinson, 2023/07/31
- Re: [PATCH] fix bind -X quoting, Chet Ramey, 2023/07/31