[ 
https://issues.apache.org/jira/browse/MWRAPPER-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17813929#comment-17813929
 ] 

ASF GitHub Bot commented on MWRAPPER-123:
-----------------------------------------

bmarwell commented on PR #117:
URL: https://github.com/apache/maven-wrapper/pull/117#issuecomment-1925305248

   I think we can replace this
   
   ```
     # 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 )
       h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$char") ) % 4294967296 ))
       idx=$(( idx + 1 ))
     done
   ``` 
   
   with this:
   
   ```
     while [ "$str" != "" ]; do
       char="${str%${str#?}}"
       h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$char") ) % 4294967296 ))
       str="${T#?}"
     done
   ```




> only-mvnw fails on AIX' ksh implementation
> ------------------------------------------
>
>                 Key: MWRAPPER-123
>                 URL: https://issues.apache.org/jira/browse/MWRAPPER-123
>             Project: Maven Wrapper
>          Issue Type: Bug
>    Affects Versions: 3.1.1
>            Reporter: Benjamin Marwell
>            Priority: Urgent
>
> the script {{only-mvnw}} contains this snippet in a line to calculate a hash:
> {code:bash}
> printf %d "'$str"
> {code}
> The idea is to convert {{$str}} to a number, where {{'}} has a special 
> meaning for {{%d}} conversion. However, there are two problems with it:
> 1. It does not work on ksh on AIX (because this conversion is not posix 
> compliant), so the script will not run on AIX.
> 2. It will only use the first letter, which is alway {{h}} (from the string 
> always being a valid URI).
> For now, replace it with the ASCII constant 104 (ASCII value of h). The 
> intended behaviour can be restored in another PR if feasible.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to