Add support to elog_base() to split messages on newlines automatically.
authorZac Medico <zmedico@gentoo.org>
Sun, 27 Jul 2008 13:31:56 +0000 (13:31 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 27 Jul 2008 13:31:56 +0000 (13:31 -0000)
Thanks to Arfrever for the suggestion.

svn path=/main/trunk/; revision=11218

bin/isolated-functions.sh

index 6faa5d656758a221649d5ef364b18c6f5c15ca71..4de6f850320e412a0c7de744c552217536dd2d0e 100755 (executable)
@@ -158,7 +158,7 @@ vecho() {
 
 # Internal logging function, don't use this in ebuilds
 elog_base() {
-       local messagetype
+       local line messagetype
        [ -z "${1}" -o -z "${T}" -o ! -d "${T}/logging" ] && return 1
        case "${1}" in
                INFO|WARN|ERROR|LOG|QA)
@@ -170,7 +170,13 @@ elog_base() {
                        return 1
                        ;;
        esac
-       echo -ne "${messagetype} $*\n\0" >> "${T}/logging/${EBUILD_PHASE:-other}"
+       save_IFS
+       IFS=$'\n'
+       for line in $* ; do
+               echo -ne "${messagetype} ${line}\n\0" >> \
+                       "${T}/logging/${EBUILD_PHASE:-other}"
+       done
+       restore_IFS
        return 0
 }