commit:     913df7648b895add3a51e96bd477d414418a7587
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 24 13:36:13 2025 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Oct 24 13:36:13 2025 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=913df764

Don't loop in space() output function

* libs/output.bash.in (space): Don't loop.

Bug: https://bugs.gentoo.org/965038#c7
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog           | 2 ++
 libs/output.bash.in | 5 +----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 57707c5..aa94856 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2025-10-24  Ulrich Müller  <[email protected]>
 
+       * libs/output.bash.in (space): Don't loop.
+
        * libs/output.bash.in (apply_text_highlights): Modify the "text"
        variable by side effect. This avoids forking a new process for
        command substitution.

diff --git a/libs/output.bash.in b/libs/output.bash.in
index 91767de..aec13c0 100644
--- a/libs/output.bash.in
+++ b/libs/output.bash.in
@@ -253,8 +253,5 @@ highlight_marker() {
 # space PUBLIC
 # Write $1 numbers of spaces
 space() {
-       local n=$1
-       while (( n-- > 0 )); do
-               echo -n " "
-       done
+       printf "%${1}s"
 }

Reply via email to