unprivileged/chown: fix bug #470992 v2.2.2
authorBenda Xu <heroxbd@gentoo.org>
Mon, 9 Sep 2013 21:43:02 +0000 (14:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 9 Sep 2013 21:43:02 +0000 (14:43 -0700)
bin/ebuild-helpers/unprivileged/chown

index cad34d947cf7bb604f2f6f2f9086ff8ea8764ac2..08fa650c551903baca4692eae23e03ac7d258b24 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2012 Gentoo Foundation
+# Copyright 2012-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 scriptpath=${BASH_SOURCE[0]}
@@ -13,6 +13,14 @@ for path in ${PATH}; do
        IFS=$' \t\n'
        output=$("${path}/${scriptname}" "$@" 2>&1)
        if [[ $? -ne 0 ]] ; then
+
+               # Avoid an extreme performance problem when the
+               # output is very long (bug #470992).
+               if [[ $(wc -l <<< "${output}") -gt 100 ]]; then
+                       output=$(head -n100 <<< "${output}")
+                       output="${output}\n ... (further messages truncated)"
+               fi
+
                source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
                if ! ___eapi_has_prefix_variables; then