Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eselect:master commit in: libs/, /
Date: Sun, 30 Oct 2016 09:17:31
Message-Id: 1477782550.a121df41e723306bdd925098ebd4a8939ac188fe.ulm@gentoo
1 commit: a121df41e723306bdd925098ebd4a8939ac188fe
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 29 23:09:10 2016 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 29 23:09:10 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect.git/commit/?id=a121df41
7
8 Ignore comment lines when parsing config files.
9
10 * libs/config.bash.in (store_config): Ignore comment lines in
11 config files and make parsing more robust, bug 598480.
12
13 ChangeLog | 5 +++++
14 libs/config.bash.in | 8 +++++---
15 2 files changed, 10 insertions(+), 3 deletions(-)
16
17 diff --git a/ChangeLog b/ChangeLog
18 index eb3db3b..e9fc937 100644
19 --- a/ChangeLog
20 +++ b/ChangeLog
21 @@ -1,3 +1,8 @@
22 +2016-10-30 Ulrich Müller <ulm@g.o>
23 +
24 + * libs/config.bash.in (store_config): Ignore comment lines in
25 + config files and make parsing more robust, bug 598480.
26 +
27 2016-06-17 Ulrich Müller <ulm@g.o>
28
29 * configure.ac: Update version to 1.4.6.
30
31 diff --git a/libs/config.bash.in b/libs/config.bash.in
32 index 80ef798..9fbecf0 100644
33 --- a/libs/config.bash.in
34 +++ b/libs/config.bash.in
35 @@ -57,9 +57,11 @@ store_config() {
36 # parse the names of all settings in the file
37 local ifs_save=${IFS} IFS=$'\n'
38 for line in ${content} ; do
39 - [[ ${line/=/} != ${line} ]] || continue
40 - line=${line/=*/}
41 - local ${line}=""
42 + line=${line##*([[:space:]])}
43 + [[ ${line} != "#"* && ${line} == *=* ]] || continue
44 + line=${line%%=*}
45 + # assignment will fail if ${line} is not a valid identifier
46 + local ${line}="" || continue
47 vars=(${vars[@]} ${line})
48 done
49 IFS=${ifs_save}