From daf7292eebe94526295b1c107a0cabe424f5922b Mon Sep 17 00:00:00 2001 From: Benjamin Marwell Date: Thu, 1 Feb 2024 08:21:49 +0100 Subject: [PATCH] [MWRAPPER-123] hash string char-by-char for AIX's ksh implementation --- maven-wrapper-distribution/src/resources/only-mvnw | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maven-wrapper-distribution/src/resources/only-mvnw b/maven-wrapper-distribution/src/resources/only-mvnw index cc908627..816c76ab 100755 --- a/maven-wrapper-distribution/src/resources/only-mvnw +++ b/maven-wrapper-distribution/src/resources/only-mvnw @@ -71,8 +71,9 @@ set_java_home() { # hash string like Java String::hashCode hash_string() { str="${1:-}" h=0 - while [ -n "$str" ]; do - h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$str") ) % 4294967296 )) + while [ "$str" != "" ]; do + char="${str%${str#?}}" + h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$char") ) % 4294967296 )) str="${str#?}" done printf %x\\n $h