Skip to content

Commit 8046e44

Browse files
author
chenby
committed
fix(scripts): Make rct script Homebrew and symlink friendly
1 parent d82e910 commit 8046e44

File tree

7 files changed

+84
-63
lines changed

7 files changed

+84
-63
lines changed

src/main/assembly/bin/rct

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/rcut

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/rdt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/ret

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/rmonitor

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/rmt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

src/main/assembly/bin/rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ if [[ "$_java" ]]; then
2121
fi
2222

2323
# Resolve script directory, handling symlinks
24-
SCRIPT_PATH="$0"
25-
while [ -L "$SCRIPT_PATH" ]; do
26-
SCRIPT_PATH=$(readlink "$SCRIPT_PATH")
27-
# If relative symlink, resolve relative to original dir
28-
if [[ "$SCRIPT_PATH" != /* ]]; then
29-
SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )/$SCRIPT_PATH"
30-
fi
24+
PRG="$0"
25+
while [ -L "$PRG" ]; do
26+
ls=$(ls -ld "$PRG")
27+
link=$(expr "$ls" : '.*-> \(.*\)$')
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
PRG="$(dirname "$PRG")/$link"
32+
fi
3133
done
32-
SCRIPT_DIR="$( cd "$( dirname "$SCRIPT_PATH" )" >/dev/null 2>&1 && pwd )"
33-
base_dir="$SCRIPT_DIR/.."
34+
35+
SCRIPT_DIR="$(cd "$(dirname "$PRG")" >/dev/null 2>&1 && pwd)"
36+
base_dir="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
3437

3538
case "$(uname -s)" in
3639
*CYGWIN*) base_dir=`cygpath -w "$base_dir"`;;

0 commit comments

Comments
 (0)