Skip to content

Commit

Permalink
HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected
Browse files Browse the repository at this point in the history
Closes #1914

Signed-off-by: Michael Stack <[email protected]>
Signed-off-by: Viraj Jasani <[email protected]>
  • Loading branch information
WenFeiYi authored and virajjasani committed Jun 18, 2020
1 parent 812d1e2 commit 0250374
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
54 changes: 32 additions & 22 deletions bin/hbase
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +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

# Detect if we are in the omnibus tarball
in_omnibus_tarball="false"
if [ -f "${HBASE_HOME}/bin/hbase-daemons.sh" ]; then
in_omnibus_tarball="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
--internal-classpath Skip attempting to use client facing jars (WARNING: unstable results between versions)
--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 ""
Expand Down Expand Up @@ -120,6 +100,36 @@ if [ $# = 0 ]; then
echo " pre-upgrade Run Pre-Upgrade validator tool"
echo " hbtop Run HBTop tool"
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

# Detect if we are in the omnibus tarball
in_omnibus_tarball="false"
if [ -f "${HBASE_HOME}/bin/hbase-daemons.sh" ]; then
in_omnibus_tarball="true"
fi

# if no args specified, show usage
if [ $# = 0 ]; then
show_usage
exit 1
fi

Expand Down
10 changes: 9 additions & 1 deletion bin/hbase-config.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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" == "--help" (
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 (
Expand Down Expand Up @@ -75,4 +83,4 @@ for %%i in (%0) do (
if not defined HBASE_BIN_PATH (
set HBASE_BIN_PATH=%%~dpi
)
)
)
4 changes: 4 additions & 0 deletions bin/hbase-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ do
shift
# shellcheck disable=SC2034
DEBUG="true"
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
Expand Down
10 changes: 10 additions & 0 deletions bin/hbase.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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" == "--help" (
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%" %*
Expand Down Expand Up @@ -448,6 +457,7 @@ goto :eof
echo where ^<command^> an option from one of these categories::
echo Options:
echo --config DIR Configuration direction to use. Default: ./conf
echo --help or -h Print this help message
echo.
echo Commands:
echo Some commands take arguments. Pass no args or -h for usage."
Expand Down

0 comments on commit 0250374

Please sign in to comment.