Patchwork [11,of,15,V5] bash_completion: simplify if-else logic

login
register
mail settings
Submitter Sean Farley
Date Nov. 26, 2013, 7:54 p.m.
Message ID <1e5decdcde0ac1767b98.1385499290@laptop.local>
Download mbox | patch
Permalink /patch/3165/
State Accepted
Commit d14f9c4a4398d343fbdf89f69f5011c80fea43bd
Headers show

Comments

Sean Farley - Nov. 26, 2013, 7:54 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1385495733 21600
#      Tue Nov 26 13:55:33 2013 -0600
# Node ID 1e5decdcde0ac1767b980c212901ca7559a92d99
# Parent  e5eb668a5d0bd5643192f2239d813e2e7a81a39f
bash_completion: simplify if-else logic

There is no change in functionality here but this makes refactoring this later
easier.

Patch

diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -238,19 +238,15 @@ 
         "_hg_cmd_$cmd"
         return 0
     fi
 
     if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
-        if [ $canonical = 1 ]; then
+        if [[ $canonical = 1 || status != "$cmd"* ]]; then
             _hg_labels
             return 0
-        elif [[ status != "$cmd"* ]]; then
-            _hg_labels
-            return 0
-        else
-            return 1
         fi
+        return 1
     fi
 
     local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}')
     [ -n "$aliascmd" ] && cmd=$aliascmd