Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15486
| Path | csiph.com!news.mixmin.net!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Муравьев Александр <amuravyev@s-terra.ru> |
| Newsgroups | gnu.bash.bug |
| Subject | compgen -F |
| Date | Tue, 8 Oct 2019 20:30:24 +0300 |
| Lines | 109 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1392.1570555848.2651.bug-bash@gnu.org> (permalink) |
| References | <85ae4659-49c5-26d8-a241-03e78c4f41a8@s-terra.ru> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | usenet.stanford.edu 1570555848 9835 209.51.188.17 (8 Oct 2019 17:30:48 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=s-terra.ru; s=mail; t=1570555824; bh=xkCQCc84CLeAGoigIHYXV8CT1ZVL4qjbQrSi7Ehn32M=; h=To:From:Subject:Date:From; b=Ix+/8jGVNC5obTYHbaE3rlCUXqGWngRqMWNAgQflnjlWT63O9dRSTYBXLnl2E7nTP QHU8imM707L1rJ/utkPt/xouZluuh1E+thTuNT4bX78IIBxTabFhmqhXlCaJT0T8P6 HmKZtPCSF0SQ2dxRyQC9kJoMiA6OEW6V6AVmfMzU= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
| Content-Language | en-US |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] |
| X-Received-From | 193.164.201.59 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <85ae4659-49c5-26d8-a241-03e78c4f41a8@s-terra.ru> |
| Xref | csiph.com gnu.bash.bug:15486 |
Show key headers only | View raw
Hello!
I am unable to use "compgen -F" and made a patch to make it works.
Please, tell me how to improve it (if it is ugly).
Hope that it will be possible to use "compgen -F" in new BASH version.
My BASH version is "5.0.11(11)-release", OS "Ubuntu 18.04.3 LTS",
machine "x86_64".
Here it is:
> diff --git a/builtins/complete.def b/builtins/complete.def
> index 76b3eedd..e253fc60 100644
> --- a/builtins/complete.def
> +++ b/builtins/complete.def
> @@ -709,6 +709,8 @@ compgen_builtin (list)
> char *word, **matches;
> char *old_line;
> int old_ind;
> + char pcomp_local[4096];
> + char *last_word = NULL;
>
> if (list == 0)
> return (EXECUTION_SUCCESS);
> @@ -753,9 +755,55 @@ compgen_builtin (list)
> /* probably don't have to save these, just being safe */
> old_line = pcomp_line;
> old_ind = pcomp_ind;
> - pcomp_line = (char *)NULL;
> - pcomp_ind = 0;
> - sl = gen_compspec_completions (cs, "compgen", word, 0, 0, 0);
> +
> + {
> + WORD_LIST *cword = list;
> + if (cword && cword->word
> + && strlen(cword->word->word) > 0)
> + {
> + last_word = cword->word->word;
> + }
> + *pcomp_local = '\0';
> + if (cword && cword->word)
> + {
> + strcat(pcomp_local, cword->word->word);
> + if (strlen(cword->word->word) > 0)
> + {
> + last_word = cword->word->word;
> + }
> + cword = cword->next;
> + }
> + while (cword)
> + {
> + if (strlen(cword->word->word) > 0)
> + {
> + last_word = cword->word->word;
> + }
> + strcat(pcomp_local, " ");
> + strcat(pcomp_local, cword->word->word);
> + cword = cword->next;
> + }
> + }
> + pcomp_line = pcomp_local;
> + pcomp_ind = strlen(pcomp_local);
> +
> + sl = gen_compspec_completions (cs, "compgen", word, 0, pcomp_ind, 0);
> + if (sl != 0 && sl->list_len == 1)
> + {
> + int last_word_len = strlen(last_word);
> + int strcmp_complete_res = strncmp(*(sl->list), last_word,
> + last_word_len);
> + if (0 == strcmp_complete_res
> + && strlen(*(sl->list)) == last_word_len + 1
> + && (*(sl->list))[last_word_len] == ' ')
> + {
> + /* User already enter this word. Go to next one. */
> + strcat(pcomp_local, " ");
> + pcomp_ind++;
> + sl = gen_compspec_completions (cs, "compgen", word, 0,
> pcomp_ind, 0);
> + }
> + }
> +
> pcomp_line = old_line;
> pcomp_ind = old_ind;
>
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
compgen -F Муравьев Александр <amuravyev@s-terra.ru> - 2019-10-08 20:30 +0300
csiph-web