[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-532-gd54db35

Ville Skyttä ville.skytta at iki.fi
Wed Nov 9 16:36:20 UTC 2011


The following commit has been merged in the master branch:
commit 22dff29dc4b320d8a5a91341c46db4dc1e484891
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Nov 9 18:35:13 2011 +0200

    _npus: Split out of lrzip for general use.

diff --git a/bash_completion b/bash_completion
index 76852c5..73ae920 100644
--- a/bash_completion
+++ b/bash_completion
@@ -888,6 +888,14 @@ _available_interfaces()
     COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
 }
 
+# Echo number of CPUs, falling back to 1 on failure.
+_ncpus()
+{
+    local var=NPROCESSORS_ONLN
+    [[ $OSTYPE == *linux* ]] && var=_$var
+    local n=$( getconf $var 2>/dev/null )
+    printf %s ${n:-1}
+}
 
 # Perform tilde (~) completion
 # @return  True (0) if completion needs further processing, 
diff --git a/completions/lrzip b/completions/lrzip
index 1569dab..da1730a 100644
--- a/completions/lrzip
+++ b/completions/lrzip
@@ -35,10 +35,7 @@ _lrzip()
             return 0
             ;;
         -p)
-            local var=NPROCESSORS_ONLN
-            [[ $OSTYPE == *linux* ]] && var=_$var
-            local n=$( getconf $var 2>/dev/null )
-            COMPREPLY=( $( compgen -W "{1..${n:-1}}" -- "$cur" ) )
+            COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) )
             return 0
             ;;
     esac

-- 
bash-completion



More information about the Bash-completion-commits mailing list