Bug 1254416

Summary: bash tab completion fails with "grep: Invalid range end"
Product: [Community] GlusterFS Reporter: Niels de Vos <ndevos>
Component: cliAssignee: ankit <anraj>
Status: CLOSED EOL QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.7.2CC: anraj, bugs
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1243108 Environment:
Last Closed: 2017-03-08 10:50:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1243108, 1318750    
Bug Blocks:    

Description Niels de Vos 2015-08-18 04:57:45 UTC
+++ This bug was initially created as a clone of Bug #1243108 +++
+++                                                           +++
+++ Use this bug to backport the change(s) from Bug #1243108  +++

With glusterfs-cli installed, bash tab completion fails to work and prints an error message:

$ gluster volgrep: Invalid range end
^C

I have tested 3.6.3 and 3.7.2, both of which exhibit the problem.

The problem is caused by the ordering of characters within an egrep bracket expression in the "_gluster_completion()" function defined in /etc/bash_completion.d/gluster.  The file contains this line:

      egrep -ao --color=never "([A-Za-z0-9_-.]+)|[[:space:]]+|." |  \

And egrep is interpreting the "-" character in that bracket expression as indicating a range is being requested, "_-." Fortunately, "_" actually comes after ".", this range expression is invalid, and egrep throws the error instead of silently not doing what was intended.

The fix is simply to swap the positions of "-" and "." in that bracket expression:

      egrep -ao --color=never "([A-Za-z0-9_.-]+)|[[:space:]]+|." |  \

With this change, bash tab completion works as intended.

--- Additional comment from Ravishankar N on 2015-07-21 14:16:44 CEST ---

Triaged this bug as a part of the weekly meeting. Paul, would you like to send a patch for this?  The workflow is here http://www.gluster.org/community/documentation/index.php/Development_Work_Flow

--- Additional comment from Anand Avati on 2015-08-18 06:03:05 CEST ---

REVIEW: http://review.gluster.org/11939 (Swap order of characters in egrep bracket expression to fix Bug 1243108.) posted (#1) for review on master by Anonymous Coward (paulds)

Comment 1 Kaushal 2017-03-08 10:50:28 UTC
This bug is getting closed because GlusteFS-3.7 has reached its end-of-life.

Note: This bug is being closed using a script. No verification has been performed to check if it still exists on newer releases of GlusterFS.
If this bug still exists in newer GlusterFS releases, please reopen this bug against the newer release.