From dee07f0c21c20354cc0667941dda5a007a6ac03b Mon Sep 17 00:00:00 2001 From: yuan Date: Tue, 7 Mar 2023 10:32:27 +0800 Subject: [PATCH] [KYUUBI #4078] [FOLLOWUP] fix shellcheck violations in scripts of /bin folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### _Why are the changes needed?_ - fix shellcheck violations in scripts of /bin folder - enable shellcheck rule checks ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #4162 from davidyuan1223/master. Closes #4078 c48ad38c7 [yuanfuyuan] remove the used blank lines 55a0a43c5 [xiaoyuandajian] Merge pull request #10 from xiaoyuandajian/fix-#4057 cb1193576 [yuan] Merge remote-tracking branch 'origin/fix-#4057' into fix-#4057 86e4e1ce0 [yuan] fix-#4057 info: modify the shellcheck errors file in ./bin 1. "$@" is a array, we want use string to compare. so update "$@" => "$*" 2. `tty` mean execute the command, we can use $(tty) replace it 3. param $# is a number, compare number should use -gt/-lt,not >/< 4. not sure the /bin/kyuubi line 63 'exit -1' need modify? so the directory bin only have a shellcheck note in /bin/kyuubi dd39efdeb [袁福元] fix-#4057 info: 1. "$@" is a array, we want use string to compare. so update "$@" => "$*" 2. `tty` mean execute the command, we can use $(tty) replace it 3. param $# is a number, compare number should use -gt/-lt,not >/< Lead-authored-by: yuan Co-authored-by: 袁福元 Co-authored-by: xiaoyuandajian <51512358+xiaoyuandajian@users.noreply.github.com> Co-authored-by: yuanfuyuan <1406957364@qq.com> Signed-off-by: liangbowen --- bin/docker-image-tool.sh | 3 +-- bin/kyuubi | 3 +-- bin/kyuubi-logo | 7 ++----- bin/stop-application.sh | 3 +-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bin/docker-image-tool.sh b/bin/docker-image-tool.sh index f3efc8bf5..14d5fe7b0 100755 --- a/bin/docker-image-tool.sh +++ b/bin/docker-image-tool.sh @@ -200,8 +200,7 @@ Examples: EOF } -# shellcheck disable=SC2199 -if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then +if [[ "$*" = *--help ]] || [[ "$*" = *-h ]]; then usage exit 0 fi diff --git a/bin/kyuubi b/bin/kyuubi index 09c8e9373..9bcca2c46 100755 --- a/bin/kyuubi +++ b/bin/kyuubi @@ -30,8 +30,7 @@ function usage() { echo " -h | --help - Show this help message" } -# shellcheck disable=SC2199 -if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then +if [[ "$*" = *--help ]] || [[ "$*" = *-h ]]; then usage exit 0 fi diff --git a/bin/kyuubi-logo b/bin/kyuubi-logo index 15a45a4bb..1f95ca02e 100755 --- a/bin/kyuubi-logo +++ b/bin/kyuubi-logo @@ -15,18 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - # Bugzilla 37848: When no TTY is available, don't output to console have_tty=0 -# shellcheck disable=SC2006 -if [[ "`tty`" != "not a tty" ]]; then +if [[ "$(tty)" != "not a tty" ]]; then have_tty=1 fi # Bugzilla 37848: When no TTY is available, don't output to console have_tty=0 -# shellcheck disable=SC2006 -if [[ "`tty`" != "not a tty" ]]; then +if [[ "$(tty)" != "not a tty" ]]; then have_tty=1 fi diff --git a/bin/stop-application.sh b/bin/stop-application.sh index b208ab505..000eb4cdd 100755 --- a/bin/stop-application.sh +++ b/bin/stop-application.sh @@ -16,8 +16,7 @@ # limitations under the License. # -# shellcheck disable=SC2071 -if [[ $# < 1 ]] ; then +if [[ $# -lt 1 ]] ; then echo "USAGE: $0 " exit 1 fi