HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected

Closes #1930

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
WenFeiYi 2020-06-19 23:06:10 +05:30 committed by Viraj Jasani
parent 404c2dd3fe
commit 655658ce36
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
4 changed files with 50 additions and 17 deletions

View File

@ -57,28 +57,15 @@
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
--help or -h Print this help message
EOF
# if no args specified, show usage
if [ $# = 0 ]; then
show_usage() {
echo "Usage: hbase [<options>] <command> [<args>]"
echo "$options_string"
echo ""
@ -108,6 +95,31 @@ 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

View File

@ -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 (

View File

@ -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

View File

@ -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%" %*