Bug 19894

Summary: Urpmi completion don't work correctly with alias grep='grep --color=always'
Product: Mageia Reporter: Raphael Gertz <mageia>
Component: RPM PackagesAssignee: Mageia tools maintainers <mageiatools>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: Normal CC: mageia
Version: CauldronKeywords: PATCH
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: urpmi-8.105-1.mga6.src.rpm CVE:
Status comment:
Attachments: Fix urpmi completion script to skip grep and sed aliases.

Description Raphael Gertz 2016-12-05 14:27:49 CET
Description of problem:
urpmi bash completion trust aliases of sed and grep where it shouldn't.

A possible fix would be to force 
Please change line 11 in /etc/bash_completion.d/urpmi to :
        | \sed -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/ /\\ /g' ) )

Please change line 27 in /etc/bash_completion.d/urpmi to :
        | \grep "^${cur//\\\\/}" ` )

Please change line 48 in /etc/bash_completion.d/urpmi to :
COMPREPLY=( $( compgen -W "$(urpmq $options --list | \grep ^$cur )" -- ) )

The backslash will disable any alias on sed or grep.

An unalias sed 2>/dev/null or unalias grep 2>/dev/null is an other option.

Version-Release number of selected component (if applicable):
urpmi-8.105-1.mga6

How reproducible:
Always

Steps to Reproduce:
1. echo "alias grep='grep --color=always'" >> ~/.bashrc
2. . ~/.bashrc
3. urpmi varni<tab>
4. urpmi ^[[01;31m^[[Kvarni^[[m^[[Ksh
Rémi Verschelde 2016-12-05 14:29:51 CET

Assignee: bugsquad => mageiatools
Severity: normal => minor

Comment 1 Raphael Gertz 2017-02-01 10:27:27 CET
Created attachment 8920 [details]
Fix urpmi completion script to skip grep and sed aliases.
Samuel Verschelde 2017-02-01 10:28:31 CET

Keywords: (none) => PATCH

Comment 2 Mageia Robot 2017-02-01 10:47:16 CET
commit 257cc397753fc1b669e7cc8c5435d7f11202847a
Author: Nicolas Lécureuil <neoclust@...>
Date:   Wed Feb 1 10:46:59 2017 +0100

     Fix bash completion to not trust aliases (mga#19894) Patch from rapsys
---
 Commit Link:
   http://gitweb.mageia.org/software/rpm/urpmi/commit/?id=257cc397753fc1b669e7cc8c5435d7f11202847a
Comment 3 Nicolas Lécureuil 2017-02-01 10:51:52 CET
tested and works OK for me

Status: NEW => RESOLVED
CC: (none) => mageia
Resolution: (none) => FIXED