On Mon, Jul 24, 2023, 7:13 PM Chet Ramey <chet.ra...@case.edu> wrote:
> On 7/19/23 12:47 PM, Grisha Levit wrote: > > On Wed, Jul 19, 2023 at 10:47 AM Chet Ramey <chet.ra...@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\"' > in my shell awk coding story , thers the quotes to get escquoted escape_deep_level deep i d wanna see such a helper function opt1 quote types opt2 if to surround string arg/s with quoted , and mainopt3 escape " ( in this case ) defaultly 1 deep but variable .. the higher the deep level number is , the more backslashes and whatever valid will appear .. basic code gen function 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 c...@case.edu http://tiswww.cwru.edu/~chet/ > > >