Re: [PATCH] Save more readline state when running compgen

2023-03-23 Thread Chet Ramey
On 3/22/23 4:33 PM, Koichi Murase wrote: Do you think calling `compgen', which leaves the state of `compopt -o filenames', etc., outside the bindable function `compete' would affect any behaviors? That's more or less the question. It's not that compgen leaves modified readline state outside a

Re: [PATCH] Save more readline state when running compgen

2023-03-22 Thread Koichi Murase
2023年3月22日(水) 22:51 Chet Ramey : > > I wouldn't say my usage is typical, but I do that in fact. I have a > > shell function to do that for an arbitrary command (which I once > > posted in help-bash [1] but now it's old. The latest is [2]) and use > > it everywhere. > > So is your function suite dep

Re: [PATCH] Save more readline state when running compgen

2023-03-22 Thread Chet Ramey
On 3/21/23 7:00 PM, Koichi Murase wrote: 2023年3月22日(水) 6:00 Greg Wooledge : I don't use programmable completion, but I could *imagine* someone using a temp file to store the results, then using mapfile to read them back in, to avoid the fork() that the command substitution uses. I wouldn't say

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Koichi Murase
2023年3月22日(水) 6:00 Greg Wooledge : > I don't use programmable completion, but I could *imagine* someone using > a temp file to store the results, then using mapfile to read them back > in, to avoid the fork() that the command substitution uses. I wouldn't say my usage is typical, but I do that in

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Grisha Levit
On Tue, Mar 21, 2023 at 5:52 PM alex xmb ratchev wrote: > On Tue, Mar 21, 2023, 22:42 Grisha Levit wrote: >> Let's say you want to know if there are any entries starting with >> `foo' in the current directory. You can do: > > i see , thank you sir > i .. mostly dont have that case ( if existing

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread alex xmb ratchev
On Tue, Mar 21, 2023, 22:42 Grisha Levit wrote: > On Tue, Mar 21, 2023 at 5:26 PM alex xmb ratchev > wrote: > > On Tue, Mar 21, 2023, 21:05 Grisha Levit wrote: > >> > >> compgen -G 'foo/*' >/dev/null && COMPREPLY=(bar) > > > > i dont get that code at all , but i like idea of speedier file filli

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Grisha Levit
On Tue, Mar 21, 2023 at 5:26 PM alex xmb ratchev wrote: > On Tue, Mar 21, 2023, 21:05 Grisha Levit wrote: >> >> compgen -G 'foo/*' >/dev/null && COMPREPLY=(bar) > > i dont get that code at all , but i like idea of speedier file filling .. can > u explain some in short ? Let's say you want to kn

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread alex xmb ratchev
On Tue, Mar 21, 2023, 21:05 Grisha Levit wrote: > On Tue, Mar 21, 2023 at 3:47 PM Chet Ramey wrote: > > OK, say you did in fact run compgen in the foreground -- very unusual > > because it's awkward to capture the possible completions that way -- to > > generate completions. > > Sorry I should h

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread alex xmb ratchev
On Tue, Mar 21, 2023, 21:05 Grisha Levit wrote: > On Tue, Mar 21, 2023 at 3:47 PM Chet Ramey wrote: > > OK, say you did in fact run compgen in the foreground -- very unusual > > because it's awkward to capture the possible completions that way -- to > > generate completions. > > Sorry I should h

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Greg Wooledge
On Tue, Mar 21, 2023 at 04:52:03PM -0400, Grisha Levit wrote: > On Tue, Mar 21, 2023 at 4:11 PM Chet Ramey wrote: > > OK, which do you think would be the more common case? Wanting the options > > used to generate completions to persist or using it in this way? > > Usually people do `COMPREPLY=($(

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Grisha Levit
On Tue, Mar 21, 2023 at 4:11 PM Chet Ramey wrote: > OK, which do you think would be the more common case? Wanting the options > used to generate completions to persist or using it in this way? Usually people do `COMPREPLY=($(compgen ...))' (or write to stdout in a command specified with `complete

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Chet Ramey
On 3/21/23 4:04 PM, Grisha Levit wrote: On Tue, Mar 21, 2023 at 3:47 PM Chet Ramey wrote: OK, say you did in fact run compgen in the foreground -- very unusual because it's awkward to capture the possible completions that way -- to generate completions. Sorry I should have explained. I hit th

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Grisha Levit
On Tue, Mar 21, 2023 at 3:47 PM Chet Ramey wrote: > OK, say you did in fact run compgen in the foreground -- very unusual > because it's awkward to capture the possible completions that way -- to > generate completions. Sorry I should have explained. I hit this issue because I was using compgen i

Re: [PATCH] Save more readline state when running compgen

2023-03-21 Thread Chet Ramey
On 3/19/23 10:08 PM, Grisha Levit wrote: Completion state is not fully restored after invoking `compgen' within a competition function. Normally, if a compspec does not specifically include one of the options that triggers filename completion, the generated completions are not treated as filenam

[PATCH] Save more readline state when running compgen

2023-03-19 Thread Grisha Levit
Completion state is not fully restored after invoking `compgen' within a competition function. Normally, if a compspec does not specifically include one of the options that triggers filename completion, the generated completions are not treated as filenames: $ complete -W '/tmp /var' cmd $ cmd /[