compiletheworld commented on code in PR #10918: URL: https://github.com/apache/doris/pull/10918#discussion_r922924574
########## bin/stop_be.sh: ########## @@ -16,14 +16,26 @@ # specific language governing permissions and limitations # under the License. -curdir=`dirname "$0"` -curdir=`cd "$curdir"; pwd` +# resolve links - $0 may be a softlink +PRG="$0" -export DORIS_HOME=`cd "$curdir/.."; pwd` -export PID_DIR=`cd "$curdir"; pwd` +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` + +export DORIS_HOME=`cd "$PRG_DIR/.." >/dev/null; pwd` +export PID_DIR=`cd "$PRGDIR" >/dev/null; pwd` signum=9 -if [ "x"$1 = "x--grace" ]; then +if [ x"$1" != x"--grace" ]; then Review Comment: This change may break the original semantic, which seems not correct. ########## bin/start_be.sh: ########## @@ -16,11 +16,31 @@ # specific language governing permissions and limitations # under the License. -curdir=$(dirname "$0") -curdir=$( - cd "$curdir" - pwd -) +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` + +export DORIS_HOME=`cd "$PRG_DIR/.." >/dev/null; pwd` +export PID_DIR=`cd "$PRGDIR" >/dev/null; pwd` Review Comment: Is `cd` necessary to evaluate `PID_DIR`? `cd` changes the current directory, which may lead to some subtle bugs. ########## bin/start_be.sh: ########## @@ -16,11 +16,31 @@ # specific language governing permissions and limitations # under the License. -curdir=$(dirname "$0") -curdir=$( - cd "$curdir" - pwd -) +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ] ; do Review Comment: Consider command `readlink` to resolve the soft link problem? ########## bin/start_be.sh: ########## @@ -16,11 +16,31 @@ # specific language governing permissions and limitations # under the License. -curdir=$(dirname "$0") -curdir=$( - cd "$curdir" - pwd -) +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` + +export DORIS_HOME=`cd "$PRG_DIR/.." >/dev/null; pwd` Review Comment: Where is `PRG_DIR` defined and what's the different between `PRG_DIR` and `PRGDIR`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org