You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2020/06/22 09:25:54 UTC

[hbase] branch branch-1.4 updated: HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected (#1950)

This is an automated email from the ASF dual-hosted git repository.

vjasani pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 1e6594f  HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected (#1950)
1e6594f is described below

commit 1e6594f05f089885487796985285f2e655308e55
Author: WenFeiYi <we...@gmail.com>
AuthorDate: Mon Jun 22 17:25:43 2020 +0800

    HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected (#1950)
    
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 bin/hbase            | 49 +++++++++++++++++++++++++++++--------------------
 bin/hbase-config.cmd |  8 ++++++++
 bin/hbase-config.sh  |  4 ++++
 bin/hbase.cmd        |  9 +++++++++
 4 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/bin/hbase b/bin/hbase
index ddcb92e..dbd7311 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -57,28 +57,13 @@
 bin=`dirname "$0"`
 bin=`cd "$bin">/dev/null; pwd`
 
-# This will set HBASE_HOME, etc.
-. "$bin"/hbase-config.sh
-
-cygwin=false
-case "`uname`" in
-CYGWIN*) cygwin=true;;
-esac
-
-# Detect if we are in hbase sources dir
-in_dev_env=false
-if [ -d "${HBASE_HOME}/target" ]; then
-  in_dev_env=true
-fi
-
 read -d '' options_string << EOF
 Options:
   --config DIR     Configuration direction to use. Default: ./conf
   --hosts HOSTS    Override the list in 'regionservers' file
   --auth-as-server Authenticate to ZooKeeper using servers configuration
 EOF
-# if no args specified, show usage
-if [ $# = 0 ]; then
+show_usage() {
   echo "Usage: hbase [<options>] <command> [<args>]"
   echo "$options_string"
   echo ""
@@ -92,11 +77,11 @@ if [ $# = 0 ]; then
   echo "  hfile           Store file analyzer"
   echo "  zkcli           Run the ZooKeeper shell"
   echo "  upgrade         Upgrade hbase"
-  echo "  master          Run an HBase HMaster node" 
-  echo "  regionserver    Run an HBase HRegionServer node" 
+  echo "  master          Run an HBase HMaster node"
+  echo "  regionserver    Run an HBase HRegionServer node"
   echo "  zookeeper       Run a Zookeeper server"
-  echo "  rest            Run an HBase REST server" 
-  echo "  thrift          Run the HBase Thrift server" 
+  echo "  rest            Run an HBase REST server"
+  echo "  thrift          Run the HBase Thrift server"
   echo "  thrift2         Run the HBase Thrift2 server"
   echo "  clean           Run the HBase clean up script"
   echo "  classpath       Dump hbase CLASSPATH"
@@ -107,6 +92,30 @@ if [ $# = 0 ]; then
   echo "  hbtop           Run the HBTop tool"
   echo "  version         Print the version"
   echo "  CLASSNAME       Run the class named CLASSNAME"
+}
+
+if [ "--help" = "$1" ] || [ "-h" = "$1" ]; then
+  show_usage
+  exit 0
+fi
+
+# This will set HBASE_HOME, etc.
+. "$bin"/hbase-config.sh
+
+cygwin=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+esac
+
+# Detect if we are in hbase sources dir
+in_dev_env=false
+if [ -d "${HBASE_HOME}/target" ]; then
+  in_dev_env=true
+fi
+
+# if no args specified, show usage
+if [ $# = 0 ]; then
+  show_usage
   exit 1
 fi
 
diff --git a/bin/hbase-config.cmd b/bin/hbase-config.cmd
index 5c1f186..d70a88e 100644
--- a/bin/hbase-config.cmd
+++ b/bin/hbase-config.cmd
@@ -33,6 +33,14 @@ if "%1" == "--config" (
   shift
   shift
 )
+if "%1" == "--help" (
+  echo Error usage! You should use it like 'hbase --help' or 'hbase -h';
+  exit /B 2
+)
+if "%1" == "-h" (
+  echo Error usage! You should use it like 'hbase --help' or 'hbase -h';
+  exit /B 2
+)
 
 @rem the root of the hbase installation
 if not defined HBASE_HOME (
diff --git a/bin/hbase-config.sh b/bin/hbase-config.sh
index 2f1a254..806b623 100644
--- a/bin/hbase-config.sh
+++ b/bin/hbase-config.sh
@@ -84,6 +84,10 @@ do
       exit 1
     fi
     shift
+  elif [ "--help" = "$1" ] || [ "-h" = "$1" ]
+  then
+    echo "Error usage! You should use it like 'hbase --help' or 'hbase -h'";
+    exit 1
   else
     # Presume we are at end of options and break
     break
diff --git a/bin/hbase.cmd b/bin/hbase.cmd
index da7bcd9..d5334fc 100644
--- a/bin/hbase.cmd
+++ b/bin/hbase.cmd
@@ -59,6 +59,15 @@ if "%HBASE_BIN_PATH:~-1%" == "\" (
   set HBASE_BIN_PATH=%HBASE_BIN_PATH:~0,-1%
 )
 
+if "%1" == "--help" (
+  goto :print_usage
+  exit /B 0
+)
+if "%1" == "-h" (
+  goto :print_usage
+  exit /B 0
+)
+
 rem This will set HBASE_HOME, etc.
 set hbase-config-script=%HBASE_BIN_PATH%\hbase-config.cmd
 call "%hbase-config-script%" %*