ZhongRuoyu commented on code in PR #1502:
URL: https://github.com/apache/solr/pull/1502#discussion_r1151667097


##########
solr/bin/solr:
##########
@@ -163,7 +163,7 @@ if [[ $? -ne 0 ]] ; then
   echo >&2 "${PATH}"
   exit 1
 else
-  JAVA_VER_NUM=$(echo "$JAVA_VER" | head -1 | awk -F '"' '/version/ {print 
$2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//')
+  JAVA_VER_NUM=$(echo "$JAVA_VER" | awk -F '"' '/version/ {print $2}' | sed 
-e's/^1\.//' | sed -e's/[._-].*$//')

Review Comment:
   To make the patch more robust, I suggest this:
   
   ```suggestion
     JAVA_VER_NUM=$(echo "$JAVA_VER" | grep -v '_JAVA_OPTIONS' | awk -F '"' 
'/version/ {print $2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//')
   ```
   
   This prevents matching any occurrence of `version` found in `_JAVA_OPTIONS`:
   
   ```console
   $ export _JAVA_OPTIONS='-Dmy.package.version="123"'
   $ JAVA_VER=$(java -version 2>&1)
   $ echo "$JAVA_VER" | awk -F '"' '/version/ {print $2}' | sed -e's/^1\.//' | 
sed -e's/[._-].*$//'
   123
   19
   $ echo "$JAVA_VER" | grep -v '_JAVA_OPTIONS' | awk -F '"' '/version/ {print 
$2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//'
   19
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to