bmarwell commented on code in PR #117:
URL: https://github.com/apache/maven-wrapper/pull/117#discussion_r1474169068


##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -70,11 +70,19 @@ 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 ))
-    str="${str#?}"
+  str="${1}"
+  length=${#str}
+  h=0
+  # strings start with index 1
+  idx=1
+
+  # lt: skip line break at end
+  while [ $idx -lt "$length" ]; do
+    char=$( printf "%s" "$str" | cut -c $idx )

Review Comment:
   Fork here, alternative is to use string index (supported by ksh and bash and 
zsh). However:
   
   ```
   In maven-wrapper-distribution/src/resources/only-mvnw line 80:
       char=${str:${idx}:1}
            ^-------------^ SC3057 (warning): In POSIX sh, string indexing is 
undefined.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to