Bug 16036 - urpmi: prevent autocompletion if the argument to complete is empty
Summary: urpmi: prevent autocompletion if the argument to complete is empty
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Low enhancement
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-24 18:13 CEST by Rémi Verschelde
Modified: 2016-11-01 12:51 CET (History)
2 users (show)

See Also:
Source RPM: bash-completion, urpmi
CVE:
Status comment:


Attachments

Description Rémi Verschelde 2015-05-24 18:13:05 CEST
We've probably all been bitten at least once, if not many times, by the fact that urpmi does not ask for confirmation when you try to autocomplete a package name, and you made a mistake like:

# urpmi task <TAB>
(note the whitespace after "task", thus urpmi tries to complete an empty string, and it can take quite a while to get the results)

A way to workaround this issue might be to prevent autocompletion if the argument to complete is empty (as above).

Reproducible: 

Steps to Reproduce:
Rémi Verschelde 2015-05-24 18:13:36 CEST

CC: (none) => thierry.vignaud

Rémi Verschelde 2015-05-24 18:17:13 CEST

Priority: Normal => Low

Thierry Vignaud 2015-05-25 17:37:08 CEST

Source RPM: urpmi => bash-completion, urpmi

Thierry Vignaud 2015-05-25 17:37:15 CEST

Hardware: i586 => All

Comment 1 Thierry Vignaud 2015-06-02 11:25:12 CEST
Guillaume, any though on how to do that?

CC: (none) => guillomovitch

Comment 2 Guillaume Rousse 2015-06-02 12:13:01 CEST
The following line in _urpmi_package function should be enough:

[ -z $cur ] && return 0

However, I don't think it would be very wise to introduce such kind of hardcoded trick in a specific completion. A configurable completion treshold, defined in a COMP_URPMI_TRESHOLD environment variable, would a be better option:

[[ ${#cur} -lt $COMP_URPMI_TRESHOLD ]] && return 0
Comment 3 Rémi Verschelde 2016-01-13 11:36:09 CET
(In reply to Guillaume Rousse from comment #2)
> 
> However, I don't think it would be very wise to introduce such kind of
> hardcoded trick in a specific completion. A configurable completion
> treshold, defined in a COMP_URPMI_TRESHOLD environment variable, would a be
> better option:
> 
> [[ ${#cur} -lt $COMP_URPMI_TRESHOLD ]] && return 0

That sounds like a good plan to me. Which package should define this variable? urpmi?
Comment 4 Guillaume Rousse 2016-01-14 20:30:53 CET
packages don't define variables, they just install files. Just document it somewhere in urpmi READMI file.
Samuel Verschelde 2016-11-01 12:51:55 CET

Assignee: bugsquad => mageiatools


Note You need to log in before you can comment on or make changes to this bug.