mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-23 11:31:31 +01:00
Escape open bracket when parsing config file.
Section header like [x86-zgb] would match any single-character
file/directory name within 6-z. Escape open brackets to prevent
config section headers from being evaluated to match local files.
BUG=chromium-os:21518
TEST=1. Create a single-character file 'u', under the same
directory where you'll run make_factory_package.
2. Create a test.conf with section header "x86-zgb".
3. ./make_factory_package.sh --config test.conf
4. Verify u is not part of the executed command.
Change-Id: Ia6178b7fc2f8d707830ee7fed54f9e5ab60d6836
Reviewed-on: http://gerrit.chromium.org/gerrit/10012
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
This commit is contained in:
parent
eeaf674db4
commit
342dbdaf10
@ -650,12 +650,10 @@ parse_and_run_config() {
|
||||
local config_file="$1"
|
||||
local -a cmds
|
||||
local cmd=""
|
||||
local line
|
||||
|
||||
echo "Read parameters from: $config_file"
|
||||
local config="$(<$config_file)"
|
||||
local IFS=$'\n'
|
||||
for line in $config
|
||||
do
|
||||
while read line; do
|
||||
if [[ "$line" =~ ^\[.*] ]]; then
|
||||
if [ -n "$cmd" ]; then
|
||||
cmds+=("$cmd")
|
||||
@ -665,7 +663,7 @@ parse_and_run_config() {
|
||||
fi
|
||||
line="${line%%#*}"
|
||||
cmd="$cmd $line"
|
||||
done
|
||||
done < "$config_file"
|
||||
if [ -n "$cmd" ]; then
|
||||
cmds+=("$cmd")
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user