Skip to content

Commit f73480f

Browse files
WenFeiYivirajjasani
authored andcommitted
HBASE-24550 Passing '-h' or '--help' to bin/hbase doesn't do as expected
Closes apache#1914 Signed-off-by: Michael Stack <stack@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
1 parent 6a57669 commit f73480f

File tree

4 files changed

+55
-23
lines changed

4 files changed

+55
-23
lines changed

bin/hbase

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,15 @@
5757
bin=`dirname "$0"`
5858
bin=`cd "$bin">/dev/null; pwd`
5959

60-
# This will set HBASE_HOME, etc.
61-
. "$bin"/hbase-config.sh
62-
63-
cygwin=false
64-
case "`uname`" in
65-
CYGWIN*) cygwin=true;;
66-
esac
67-
68-
# Detect if we are in hbase sources dir
69-
in_dev_env=false
70-
if [ -d "${HBASE_HOME}/target" ]; then
71-
in_dev_env=true
72-
fi
73-
74-
# Detect if we are in the omnibus tarball
75-
in_omnibus_tarball="false"
76-
if [ -f "${HBASE_HOME}/bin/hbase-daemons.sh" ]; then
77-
in_omnibus_tarball="true"
78-
fi
79-
8060
read -d '' options_string << EOF
8161
Options:
8262
--config DIR Configuration direction to use. Default: ./conf
8363
--hosts HOSTS Override the list in 'regionservers' file
8464
--auth-as-server Authenticate to ZooKeeper using servers configuration
8565
--internal-classpath Skip attempting to use client facing jars (WARNING: unstable results between versions)
66+
--help or -h Print this help message
8667
EOF
87-
# if no args specified, show usage
88-
if [ $# = 0 ]; then
68+
show_usage() {
8969
echo "Usage: hbase [<options>] <command> [<args>]"
9070
echo "$options_string"
9171
echo ""
@@ -122,6 +102,36 @@ if [ $# = 0 ]; then
122102
echo " pre-upgrade Run Pre-Upgrade validator tool"
123103
echo " hbtop Run HBTop tool"
124104
echo " CLASSNAME Run the class named CLASSNAME"
105+
}
106+
107+
if [ "--help" = "$1" ] || [ "-h" = "$1" ]; then
108+
show_usage
109+
exit 0
110+
fi
111+
112+
# This will set HBASE_HOME, etc.
113+
. "$bin"/hbase-config.sh
114+
115+
cygwin=false
116+
case "`uname`" in
117+
CYGWIN*) cygwin=true;;
118+
esac
119+
120+
# Detect if we are in hbase sources dir
121+
in_dev_env=false
122+
if [ -d "${HBASE_HOME}/target" ]; then
123+
in_dev_env=true
124+
fi
125+
126+
# Detect if we are in the omnibus tarball
127+
in_omnibus_tarball="false"
128+
if [ -f "${HBASE_HOME}/bin/hbase-daemons.sh" ]; then
129+
in_omnibus_tarball="true"
130+
fi
131+
132+
# if no args specified, show usage
133+
if [ $# = 0 ]; then
134+
show_usage
125135
exit 1
126136
fi
127137

bin/hbase-config.cmd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ if "%1" == "--config" (
3333
shift
3434
shift
3535
)
36+
if "%1" == "--help" (
37+
echo Error usage! You should use it like 'hbase --help' or 'hbase -h';
38+
exit /B 2
39+
)
40+
if "%1" == "--help" (
41+
echo Error usage! You should use it like 'hbase --help' or 'hbase -h';
42+
exit /B 2
43+
)
3644

3745
@rem the root of the hbase installation
3846
if not defined HBASE_HOME (
@@ -75,4 +83,4 @@ for %%i in (%0) do (
7583
if not defined HBASE_BIN_PATH (
7684
set HBASE_BIN_PATH=%%~dpi
7785
)
78-
)
86+
)

bin/hbase-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ do
9494
shift
9595
# shellcheck disable=SC2034
9696
DEBUG="true"
97+
elif [ "--help" = "$1" ] || [ "-h" = "$1" ]
98+
then
99+
echo "Error usage! You should use it like 'hbase --help' or 'hbase -h'";
100+
exit 1
97101
else
98102
# Presume we are at end of options and break
99103
break

bin/hbase.cmd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ if "%HBASE_BIN_PATH:~-1%" == "\" (
5959
set HBASE_BIN_PATH=%HBASE_BIN_PATH:~0,-1%
6060
)
6161

62+
if "%1" == "--help" (
63+
goto :print_usage
64+
exit /B 0
65+
)
66+
if "%1" == "--help" (
67+
goto :print_usage
68+
exit /B 0
69+
)
70+
6271
rem This will set HBASE_HOME, etc.
6372
set hbase-config-script=%HBASE_BIN_PATH%\hbase-config.cmd
6473
call "%hbase-config-script%" %*
@@ -448,6 +457,7 @@ goto :eof
448457
echo where ^<command^> an option from one of these categories::
449458
echo Options:
450459
echo --config DIR Configuration direction to use. Default: ./conf
460+
echo --help or -h Print this help message
451461
echo.
452462
echo Commands:
453463
echo Some commands take arguments. Pass no args or -h for usage."

0 commit comments

Comments
 (0)