You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/11/01 16:54:41 UTC

[GitHub] [rocketmq] gorden5566 opened a new issue #3450: sed: illegal option -- r

gorden5566 opened a new issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450


   When I start nameserver on my Mac by the `mqnamesrv` script
   
   ```
   sh ./bin/mqnamesrv
   ```
   
   it raise an error
   
   ```
   sed: illegal option -- r
   usage: sed script [-Ealn] [-i extension] [file ...]
          sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
   ```
   
   which lead to `JAVA_MAJOR_VERSION` always be empty,  in other words, it cannot recognize JDK gt than 1.8
   
   The reason is that `sed` on osx has no `-r` option
   
   We can test if the kernel is `Darwin`, and then decide how to get `JAVA_MAJOR_VERSION` by the result
   
   ```
   case "`uname`" in
       Darwin)
           JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
       ;;
       *)
           JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | sed -r -n 's/.* version "([0-9]*).*$/\1/p')
       ;;
   esac
   ```
   
   What do you guys think?
   
   reference #2848 
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] panzhi33 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
panzhi33 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957040215


   https://github.com/Bash-it/bash-it/issues/634  
   Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] gorden5566 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
gorden5566 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957402327


   Good idea. I've read the ISSUE, it seems that the problem remains unsolved
   
   > [Bash-it/bash-it#634](https://github.com/Bash-it/bash-it/issues/634) Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION
   
   Besides, I've tried to find another command but failed
   
   Maybe we can obtain `JAVA_MAJOR_VERSION` at runtime before start NAMESERVER, however it will introduce new dependencies


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] panzhi33 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
panzhi33 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957040215


   https://github.com/Bash-it/bash-it/issues/634  
   Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] gorden5566 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
gorden5566 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-964371793


   > Will the following command fulfill your requirement, which is not used option `-r` `JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1)`
   
   I test the script for several java version, it works fine
   
   ```
   result -> java version
   
   8 -> java version "1.8.0_201"
   9 -> java version "9.0.4"
   10 -> java version "10" 2018-03-20
   10 -> java version "10.0.1" 2018-04-17
   17 -> openjdk version "17" 2021-09-14
   17 -> openjdk version "17.0.1" 2021-10-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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] gorden5566 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
gorden5566 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957402327


   Good idea. I've read the ISSUE, it seems that the problem remains unsolved
   
   > [Bash-it/bash-it#634](https://github.com/Bash-it/bash-it/issues/634) Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION
   
   Besides, I've tried to find another command but failed
   
   Maybe we can obtain `JAVA_MAJOR_VERSION` at runtime before start NAMESERVER, however it will introduce new dependencies


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] gorden5566 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
gorden5566 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957402327


   Good idea. I've read the ISSUE, it seems that the problem remains unsolved
   
   > [Bash-it/bash-it#634](https://github.com/Bash-it/bash-it/issues/634) Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION
   
   Besides, I've tried to find another command but failed
   
   Maybe we can obtain `JAVA_MAJOR_VERSION` at runtime before start NAMESERVER, however it will introduce new dependencies


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] panzhi33 commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
panzhi33 commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-957040215


   https://github.com/Bash-it/bash-it/issues/634  
   Can think about whether there are other ways to replace the sed command to obtain JAVA_MAJOR_VERSION


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] ltamber commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
ltamber commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-964056992


   Will the following command fulfill your requirement, which is not used option `-r`
   `JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1)` 


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] ltamber commented on issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
ltamber commented on issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450#issuecomment-964741900


   > I test the script for several java version, it works fine
   > 
   > ```
   > result -> java version
   > 
   > 8 -> java version "1.8.0_201"
   > 9 -> java version "9.0.4"
   > 10 -> java version "10" 2018-03-20
   > 10 -> java version "10.0.1" 2018-04-17
   > 17 -> openjdk version "17" 2021-09-14
   > 17 -> openjdk version "17.0.1" 2021-10-19
   > ```
   
   OK, In this pr #3224, the JAVA_MAJOR_VERSION has also been changed.


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq] gorden5566 closed issue #3450: sed: illegal option -- r

Posted by GitBox <gi...@apache.org>.
gorden5566 closed issue #3450:
URL: https://github.com/apache/rocketmq/issues/3450


   


-- 
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: dev-unsubscribe@rocketmq.apache.org

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