diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-09-26 04:33:42 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-09-26 04:33:42 +0000 |
commit | a10575d40b4b25c748a74d138f2be8ca948dcf32 (patch) | |
tree | 79f89c370aa8137be64ed97aef925b1efca4c3d6 | |
parent | 90d4deee425f81b91895235b1c47398f6fd1c39f (diff) | |
download | portage-a10575d40b4b25c748a74d138f2be8ca948dcf32.tar.gz portage-a10575d40b4b25c748a74d138f2be8ca948dcf32.tar.bz2 portage-a10575d40b4b25c748a74d138f2be8ca948dcf32.zip |
tweak get_config() so that it only executes one external
binary (sed) instead of chaining multiple ones (trunk r7798)
svn path=/main/branches/2.1.2/; revision=7826
-rwxr-xr-x | bin/etc-update | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/bin/etc-update b/bin/etc-update index 0b0e3dede..0a6a79e9c 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -17,15 +17,21 @@ if type -P gsed >/dev/null ; then fi function get_config() { - item=$1 - - # First strip off comment lines, then grab the configuration - # item. If there's more than one of the same configuration item, - # then allow the last setting to take precedence. - local result - result=$(cut -d'#' -f1-1 ${PORTAGE_CONFIGROOT}etc/etc-update.conf | \ - sed -ne "s/^ *$item *= *\([\"']\{0,1\}\)\(.*\)\1/\2/p" |sed -e '$p;d') - eval echo $result + # the sed here does: + # - strip off comments + # - match lines that set item in question + # - delete the "item =" part + # - store the actual value into the hold space + # - on the last line, restore the hold space and print it + # If there's more than one of the same configuration item, then + # the store to the hold space clobbers previous value so the last + # setting takes precedence. + local item=$1 + eval echo $(sed -n \ + -e 's:[[:space:]]*#.*$::' \ + -e "/^[[:space:]]*$item[[:space:]]*=/{s:[^=]*=[[:space:]]*\([\"']\{0,1\}\)\(.*\)\1:\2:;h}" \ + -e '${g;p}' \ + "${PORTAGE_CONFIGROOT}"etc/etc-update.conf) } function scan() { |