From: Jacob Keller Date: Thu, 27 Mar 2014 18:40:04 +0000 (-0700) Subject: aiaiai: split sed project listing from list_projects X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ae9f6aead39b41e48836c7f6dd7d579e49cc65d9;p=users%2Fdedekind%2Faiaiai.git aiaiai: split sed project listing from list_projects 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. Artem: re-named the function for a bit better readability. Signed-off-by: Jacob Keller Signed-off-by: Artem Bityutskiy --- diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions index 20e4826..b840f4e 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\"" } +# Get the list of projects from config file "$1". +get_cfgfile_projects_list() +{ + 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 c5b5a3d..0692894 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 + get_cfgfile_projects_list "$cfgfile" | \ + while read -r prj; do # Get project description local descr ini_config_get_or_die descr "$cfgfile" "prj_$prj" "description"