summaryrefslogtreecommitdiff
blob: 55a9781ebd30e5c2024877f1b9d752cf53678b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
commit 86574164df810ecbd53ae841c15b38e5b06dc068
Author: Ville Skyttä <ville.skytta@iki.fi>
Date:   Tue Apr 14 00:46:12 2009 +0300

    Always use /etc/shells for chsh -s completion, don't complete on
    comment lines in it.
    
    Invoking chsh -l does unwanted things on some systems, such as FreeBSD.

diff --git a/bash_completion b/bash_completion
index e50da69..6f84e31 100644
--- a/bash_completion
+++ b/bash_completion
@@ -2569,13 +2569,10 @@ _chsh()
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
 	if [ "$prev" = "-s" ]; then
-	  if [ -f /etc/debian_version ]; then
-	    COMPREPLY=( $( </etc/shells ) )
-	  else
-	    COMPREPLY=( $( chsh -l | grep "^$cur" ) )
-	  fi
+		COMPREPLY=( $( compgen -W '$( grep "^[[:space:]]*/" \
+				/etc/shells 2>/dev/null )' -- $cur ) )
 	else
-	  COMPREPLY=( $( compgen -u -- $cur ) )
+		COMPREPLY=( $( compgen -u -- $cur ) )
 	fi
 
 	return 0