On 12/3/24 11:48 PM, Keith Thompson wrote:
An easier workaround might have been removing `:' from COMP_WORDBREAKS.Sure, but that would affect all completions. I only want to change how completions work for my one custom command.
Sure. You have to determine how many commands you're completing take arguments with embedded colons.
Escaping the colons with backslashes doesn't seem to work:You have to quote the colons on the command line so readline breaks the words it sends to programmable completion like you want. That's what this FAQ text (which predates programmable completion) means:When you wrote "on the command line", I thought you were referring to the command line with the complete" command. If you meant escaping colons on the command line with the "say" command, that's not useful to me (and I haven't been able to get it to work anyway).
That's what you have to do, yes.
Can you clarify with an example? So far, I haven't found a solution that's easier than just changing the syntax of my command to use '/' rather than ':' (which I've done).
It's the difference between these two cases. When programmable completion calls a shell function specified with -F, the second argument is the word being completed, so we can tell what readline thinks it's completing: $ foo() { echo comp_word: "$2" ; } $ complete -F foo say $ say abc:comp_word: <--- no backslash escape $ say abc\:comp_word: abc\: <---- backslash escaped colon $ You can see the different words to be completed. Your completion function can react accordingly. If you want readline to keep the backslash there, you have to tell programmable completion to quote the match, as you note:
It looks like "-o filenames" is pretty close to what I want. I'd rather not have the backslashes appear when I type <TAB>, but I can live with that.
If you want readline's completion to ignore the colon and not to use it to break words, you have to quote it. That's the bottom line. Chet -- ``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature