Skip to content

Commit

Permalink
[MWRAPPER-123] hash string char-by-char for AIX's ksh implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarwell committed Feb 3, 2024
1 parent 021a333 commit daf7292
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions maven-wrapper-distribution/src/resources/only-mvnw
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit daf7292

Please sign in to comment.