commit:     a121df41e723306bdd925098ebd4a8939ac188fe
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 23:09:10 2016 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 23:09:10 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=a121df41

Ignore comment lines when parsing config files.

* libs/config.bash.in (store_config): Ignore comment lines in
config files and make parsing more robust, bug 598480.

 ChangeLog           | 5 +++++
 libs/config.bash.in | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eb3db3b..e9fc937 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-30  Ulrich Müller  <[email protected]>
+
+       * libs/config.bash.in (store_config): Ignore comment lines in
+       config files and make parsing more robust, bug 598480.
+
 2016-06-17  Ulrich Müller  <[email protected]>
 
        * configure.ac: Update version to 1.4.6.

diff --git a/libs/config.bash.in b/libs/config.bash.in
index 80ef798..9fbecf0 100644
--- a/libs/config.bash.in
+++ b/libs/config.bash.in
@@ -57,9 +57,11 @@ store_config() {
                # parse the names of all settings in the file
                local ifs_save=${IFS} IFS=$'\n'
                for line in ${content} ; do
-                       [[ ${line/=/} != ${line} ]] || continue
-                       line=${line/=*/}
-                       local ${line}=""
+                       line=${line##*([[:space:]])}
+                       [[ ${line} != "#"* && ${line} == *=* ]] || continue
+                       line=${line%%=*}
+                       # assignment will fail if ${line} is not a valid 
identifier
+                       local ${line}="" || continue
                        vars=(${vars[@]} ${line})
                done
                IFS=${ifs_save}

Reply via email to