Fix config file section header regex.

Fix section header regex so that bracket expansion syntax won't be
recognized as section header. The only requirement is that section
header must start at the beginning of a line.

BUG=chrome-os-partner:5850
TEST=1. Create a config file (mp_factory.conf) with the following
        content:
        [x86-zgb]
        --factory ~/trunk/src/build/images/${BOARD}/latest/chromiumos_factory_image.bin
        --release ~/trunk/src/build/images/${BOARD}/latest/[Cc]hromiumos_image.bin
        --hwid_updater ~/trunk/src/platform/[Cc]hromeos-hwid/hwid_bundle_zgb.sh
        --firmware_updater none
        --detect_release_image  # Comment.

        # More comments.
        [x86-zgb-he]
        --subfolder x86-zgb-he
        --factory ~/trunk/src/build/images/${BOARD}/latest/chromiumos_factory_image.bin
        --release ~/trunk/src/build/images/${BOARD}/latest/chromiumos_image.bin
        --hwid_updater ~/trunk/src/platform/chromeos-hwid/hwid_bundle_zgb.sh
        --firmware_updater none
        --detect_release_image

     2. BOARD=x86-zgb ./make_factory_package.sh --config mp_factory.conf

Change-Id: I4d1475a5e513e7e0e06a5c3c6d46d13e2120668c
Reviewed-on: http://gerrit.chromium.org/gerrit/7698
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Chinyue Chen 2011-09-14 15:26:32 +08:00 committed by chrome-bot
parent feb896d363
commit 8e6b452f4e

View File

@ -630,7 +630,8 @@ parse_and_run_config() {
# [section2]
# --yet_another_param
#
# Note that it's not allowed to read from config file recursively.
# Note that a section header must start at the beginning of a line.
# And it's not allowed to read from config file recursively.
local config_file="$1"
local -a cmds
@ -641,7 +642,7 @@ parse_and_run_config() {
local IFS=$'\n'
for line in $config
do
if [[ "$line" =~ \[.*\] ]]; then
if [[ "$line" =~ ^\[.*] ]]; then
if [ -n "$cmd" ]; then
cmds+=("$cmd")
cmd=""