[PATCH RFC aiaiai 06/11] aiaiai: split sed project listing from list_projects

Jacob Keller jacob.e.keller at intel.com
Thu Mar 27 11:40:04 PDT 2014


In order to allow other places such as hooks to list the projects,
seperate out the sed script into its own function. This enables less
code duplication if another script wants to list all projects in a
cfgfile.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 email/aiaiai-email-sh-functions  | 8 ++++++++
 email/aiaiai-email-test-patchset | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 20e482603d73..4e9f34936aaf 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -134,6 +134,14 @@ ini_config_get_or_die()
 	eval "$var=\"\$result\""
 }
 
+# Parse the project names supported by this cfgfile.
+parse_config_supported_projects()
+{
+	local cfgfile="$1"
+
+	LC_ALL=C sed -n -e "s/^\[prj_\(.*\)\]$/\1/p" "$cfgfile"
+}
+
 # Parse the "global" section of the config file. The result is a set of
 # per-option variables and their values are exactly as in the configuration
 # file:
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index c5b5a3d78b59..a3b7280e92ea 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -68,8 +68,8 @@ list_projects()
 {
 	local prj
 
-	LC_ALL=C sed -n -e "s/^\[prj_\(.*\)\]$/\1/p" "$cfgfile" | \
-	    while read -r prj; do
+	parse_config_supported_projects "$cfgfile" | \
+	while read -r prj; do
 		# Get project description
 		local descr
 		ini_config_get_or_die descr "$cfgfile" "prj_$prj" "description"
-- 
1.8.3.1




More information about the aiaiai mailing list