From 55d8f80d03965dd3eab7b969688c25fd4f2fa2ec Mon Sep 17 00:00:00 2001 From: "luke.miao" <282583553@qq.com> Date: Wed, 28 Feb 2024 17:55:14 +0800 Subject: [PATCH] Code optimization removed the null eval statement code if os400 is true in the script --- bin/ciphers.sh | 10 +--------- bin/configtest.sh | 10 +--------- bin/digest.sh | 11 ++--------- bin/migrate.sh | 18 +++++------------- bin/shutdown.sh | 18 +++++------------- bin/startup.sh | 18 +++++------------- bin/version.sh | 10 +--------- 7 files changed, 20 insertions(+), 75 deletions(-) diff --git a/bin/ciphers.sh b/bin/ciphers.sh index d4a87b58739c..888d8e8b62ca 100755 --- a/bin/ciphers.sh +++ b/bin/ciphers.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=tool-wrapper.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 - fi fi exec "$PRGDIR"/"$EXECUTABLE" org.apache.tomcat.util.net.openssl.ciphers.OpenSSLCipherConfigurationParser "$@" diff --git a/bin/configtest.sh b/bin/configtest.sh index 9a8ebffd73d1..869258710261 100755 --- a/bin/configtest.sh +++ b/bin/configtest.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 - fi fi exec "$PRGDIR"/"$EXECUTABLE" configtest "$@" diff --git a/bin/digest.sh b/bin/digest.sh index 62ed5d0a1e7c..6b2b7538b656 100755 --- a/bin/digest.sh +++ b/bin/digest.sh @@ -42,19 +42,12 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=tool-wrapper.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 - fi fi + exec "$PRGDIR"/"$EXECUTABLE" -server org.apache.catalina.realm.RealmBase "$@" diff --git a/bin/migrate.sh b/bin/migrate.sh index d4542079fe12..e0787595e6ac 100755 --- a/bin/migrate.sh +++ b/bin/migrate.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=tool-wrapper.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then + echo "Cannot find $PRGDIR/$EXECUTABLE" + echo "The file is absent or does not have execute permission" + echo "This file is needed to run this program" + exit 1 fi exec "$PRGDIR"/"$EXECUTABLE" -server org.apache.tomcat.jakartaee.MigrationCLI "$@" diff --git a/bin/shutdown.sh b/bin/shutdown.sh index cd0c97dc2121..1ae4908ed91a 100755 --- a/bin/shutdown.sh +++ b/bin/shutdown.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then + echo "Cannot find $PRGDIR/$EXECUTABLE" + echo "The file is absent or does not have execute permission" + echo "This file is needed to run this program" + exit 1 fi exec "$PRGDIR"/"$EXECUTABLE" stop "$@" diff --git a/bin/startup.sh b/bin/startup.sh index 7b102875486f..b2e4bc0698cc 100755 --- a/bin/startup.sh +++ b/bin/startup.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then + echo "Cannot find $PRGDIR/$EXECUTABLE" + echo "The file is absent or does not have execute permission" + echo "This file is needed to run this program" + exit 1 fi exec "$PRGDIR"/"$EXECUTABLE" start "$@" diff --git a/bin/version.sh b/bin/version.sh index 1cb19bdaa0a1..b2a0a023dc9f 100755 --- a/bin/version.sh +++ b/bin/version.sh @@ -42,19 +42,11 @@ PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists -if $os400; then - # -x will Only work on the os400 if the files are: - # 1. owned by the user - # 2. owned by the PRIMARY group of the user - # this will not work if the user belongs in secondary groups - eval -else - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then +if ! $os400 && [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 - fi fi exec "$PRGDIR"/"$EXECUTABLE" version "$@"