commit: e7fcb620dec7ada18eded8c805ac60849a0a09f3
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jun 5 12:41:02 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 5 12:53:00 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e7fcb620
phase-functions.sh: work around du(1) not conforming to POSIX
The POSIX specification clearly states that the output format of the
du(1) utility should be in the following format.
"%d %s\n", <size>, <pathname>
Alas, the prevailing implementations flout this requirement, even where
any of the following conditions hold true:
- POSIXLY_CORRECT=1 is defined in the environment
- STDOUT is something other than a terminal
- the -s option isn't specified
Instead, the offending implementations employ <tab> as a field delimiter.
# du -sk /var/empty | od -tx1 -c
0000000 30 09 2f 76 61 72 2f 65 6d 70 74 79 0a
0 \t / v a r / e m p t y \n
Work around this by stripping from the first occuring [[:blank:]] character.
Fixes: 5746a0538af080ee4953f5bb43c61852ba4fff72
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-functions.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index ed32073111..9f6662ead4 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -638,8 +638,8 @@ __dyn_install() {
nsz=$(du -ks "${WORKDIR}")
isz=$(du -ks "${D}")
- nsz=${nsz%% *}
- isz=${isz%% *}
+ nsz=${nsz%%[[:blank:]]*}
+ isz=${isz%%[[:blank:]]*}
# align $1 to the right to the width of the widest of $1 and $2
padl() {