[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 5c0e30473fa12342d9b382bc7711b81ac07f528f

Ville Skyttä ville.skytta at iki.fi
Tue Apr 14 11:46:37 UTC 2009


The following commit has been merged in the master branch:
commit 5c0e30473fa12342d9b382bc7711b81ac07f528f
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Apr 14 14:45:46 2009 +0300

    Add /etc/pki/tls/openssl.cnf to list of default openssl config files, search for default ones only if -config is not given.

diff --git a/CHANGES b/CHANGES
index d5327e5..f5db787 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,6 +27,8 @@ bash-completion (1.x)
   * Add more mod-like audio file extensions for xine-based players and timidity.
   * Complete on plain alternatives like update-alternatives.
   * Rename installed_alternatives() to _installed_alternatives().
+  * Add /etc/pki/tls/openssl.cnf to list of default openssl config files,
+    search for default ones only if -config is not given.
 
   [ Todd Zullinger ]
   * Make yum complete on filenames after install, deplist, update and upgrade
diff --git a/bash_completion b/bash_completion
index 5a47d2b..dfcf518 100644
--- a/bash_completion
+++ b/bash_completion
@@ -3548,17 +3548,21 @@ complete -F _bzip2 $filenames bzip2
 have openssl && {
 _openssl_sections()
 {
-	local config
+	local config f
 
-	config=/etc/ssl/openssl.cnf
-	[ ! -f $config ] && config=/usr/share/ssl/openssl.cnf
 	for (( i=2; i < COMP_CWORD; i++ )); do
 		if [[ "${COMP_WORDS[i]}" == -config ]]; then
 			config=${COMP_WORDS[i+1]}
 			break
 		fi
 	done
-	[ ! -f $config ] && return 0
+	if [ -z "$config" ]; then
+		for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
+			/usr/share/ssl/openssl.cnf; do
+			[ -f $f ] && config=$f && break
+		done
+	fi
+	[ ! -f "$config" ] && return 0
 
 	COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
 }
diff --git a/to_review/openssl b/to_review/openssl
index e5d721d..1a04d9b 100644
--- a/to_review/openssl
+++ b/to_review/openssl
@@ -6,10 +6,7 @@
 have openssl && {
 _openssl_sections()
 {
-	local config
-
-	# start with default configuration
-	config=/etc/pki/tls/openssl.cnf
+	local config f
 
 	# check if a specific configuration file is used
 	for (( i=2; i < COMP_CWORD; i++ )); do
@@ -19,7 +16,15 @@ _openssl_sections()
 		fi
 	done
 
-	[ ! -f $config ] && return 0
+	# if no config given, check some usual default locations
+	if [ -z "$config" ]; then
+		for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
+			/usr/share/ssl/openssl.cnf; do
+			[ -f $f ] && config=$f && break
+		done
+	fi
+
+	[ ! -f "$config" ] && return 0
 
 	COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
 }

-- 
bash-completion



More information about the Bash-completion-commits mailing list